Reputation: 3071
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.
<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. Below is the adb shell command I was trying.
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:
[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>
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?
Upvotes: 1
Views: 504
Reputation: 1185
if your activity is under activitys folder then try,
<activity
android:name="activitys.MainActivity"
android:label="@string/app_name">
Upvotes: 1