简体   繁体   English

Android Xamarin中的深层链接

[英]Deep-linking in android xamarin

I have a requirement where I would like my app to be opened from an email link. 我有一个要求从电子邮件链接打开我的应用程序的要求。 I tried by adding the following code in AndroidManifest file. 我尝试在AndroidManifest文件中添加以下代码。

<activity
android:name=".MainActivity"
android:label="@string/app_name">
<!-- Accept chrome links -->
<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="http"
          android:host="example.com"
        android:pathPrefix="/"/>
</intent-filter>
<!-- Accept adb data flag -->
<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http"
          android:host="example.com"/>
</intent-filter>

But it didn't work both from abd shell as well as chrome link. 但是从abd shell以及chrome链接都无法使用。 Below is the adb shell command I was trying. 下面是我正在尝试的adb shell命令。

adb shell am start -a android.intent.action.VIEW -d "http://example.com" QRcodeScanner.QRcodeScanner

It opened up tha app but then I was getting error: 它打开了应用程序,但随后出现错误:

QRcodeScanner.QRcodeScanner.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "QRcodeScanner.QRcodeScanner.MainActivity" on path: DexPathList[[zip file "/data/app/QRcodeScanner.QRcodeScanner-1/base.apk"],nativeLibraryDirectories=[/data/app/QRcodeScanner.QRcodeScanner-1/lib/arm64, /data/app/QRcodeScanner.QRcodeScanner-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]

Finally, I got an example somewhere that states to add an intent filter in the activity. 最后,我在某处得到一个示例,该示例指出要在活动中添加一个意图过滤器。 So below is the code which worked for adb command: 因此,以下是适用于adb命令的代码:

   [IntentFilter(new[] { Intent.ActionView },
          Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
          DataScheme = "http",
          DataHost = "example.com",
          AutoVerify = true)]

But it didn't work from chrome link: <a href=”http://example.com”>app_link</a> 但这不适用于Chrome链接: <a href=”http://example.com”>app_link</a>

My activity is in the root folder at present but I would later be moving it to activities folder under root folder. 我的活动当前位于根文件夹中,但稍后将其移动到根文件夹下的活动文件夹中。 Will it make a difference? 会有所作为吗?

Also, how to retrieve data from the URL link in MainActivity? 另外,如何从MainActivity的URL链接中检索数据?

if your activity is under activitys folder then try, 如果您的活动在“活动”文件夹下,请尝试,

<activity
android:name="activitys.MainActivity"
android:label="@string/app_name">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM