Starting Android app from app link not working. Why not?

fbs419 46 Reputation points
2022-04-08T14:53:11.943+00:00

Using Xamarin with C#. What I want is to start my app based on a link in an email or sms. It doesn't have to be an http or https scheme. I am trying that and can't get it to work. I am doing the standard stuff (names changed):

<activity android:name=".MyActivity" android:launchMode="singleTask" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="www.mysite.com"
android:pathPrefix="/myapp"
android:scheme="https" />
</intent-filter>
</activity>

but when I send myself a text with https://www.mysite.com/myapp it doesn't work. I just get the 404 error (since that url does not really exist on our website).

I thought I had to put a name attribute in the declaration of MyActivity (in MyActivity.cs), but when I do that, I get a compile error:

xxx.MyActivity at AndroidManifest.xml:159:5-164:16 duplicated with element declared at AndroidManifest.xml:101:5-108:16 (I changed this to xxx to obscure real name)

So I have no idea why this doesn't work. I don't really need an https or http scheme -- I really just want something like

com.mysite.myapp://myapp

but I figured I would test with an http scheme since it would show up as a hyperlink in the text. I'm sure I had this working a few years ago. I am missing something here. Did something change? What is the best way to do this? Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,291 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,021 Reputation points Microsoft Vendor
    2022-04-11T06:23:12.327+00:00

    Hello,

    There's nothing wrong with how you started.

    I noticed that you used https as your scheme. In my testing, I will open a browser and get a 404 response when use HTTP or HTTPS scheme.

    You can try the following steps:

    Step1. Use a customized string as your scheme, such as 'myapp'.

    Step2. Send a link to your web server page in your SMS message.

    Step3. In the web page, you need to use redirection function to your URL, such as adding JavaScript code window.location.href="yourURL.

    In the documentation, there has shown the other way: Deep-Link.

    You can refer to this documentation from Configuring App-Linking in Android 6.0 and Add Android App Links for sample.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful