Hello, I'm working on launching my app from a URL....
# android
d
Hello, I'm working on launching my app from a URL. I have the intent-filter set up in my manifest:
Copy code
<activity
			android:name=".MyTargetActivity"
			android:screenOrientation="portrait">

			<intent-filter android:autoVerify="true">
				<action android:name="android.intent.action.VIEW" />

				<category android:name="android.intent.category.DEFAULT" />
				<category android:name="android.intent.category.BROWSABLE" />

				<data
					android:host="my.host.com"
					android:scheme="https" />
				<data
					android:host="my.host.com"
					android:scheme="http" />
			</intent-filter>
		</activity>
I've created the intent from the URL:
Copy code
val url: HttpUrl = HttpUrl.Builder()
			.scheme("https")
			.host("<http://my.host.com|my.host.com>")
			.addPathSegment("invite")
			.addQueryParameter("voucher", voucherContents)
			.build()
		val sendIntent: Intent = Intent().apply {
			action = Intent.ACTION_SEND
			putExtra(Intent.EXTRA_TEXT, url.toString())
			type = "text/plain"
			toUri(0)
		}
		val shareIntent = Intent.createChooser(sendIntent, url.host)
		startActivity(context, shareIntent, null)
This pops up a chooser window where I can select an app or copy to clipboard. I choose the latter and then open up an app such as Slack or Sheets or something and paste it in. When I click the URL link I just pasted, it opens MyTargetActivity successfully, but it's in the app that opened it rather than a new application. How do I get it to launch as a standalone application? (I've also written the server part and gotten that working. I can rummage that up if needed.)
ūüė∂ 4
u
You may try firebase dynamic link
d
I'll look into them. Is there no way to do it with the applink though? I feel like I'm mostly there. Am I missing a url flag perhaps or an intent-filter category?
d
Maybe you can set activity launchMode = ‚ÄúSingleTask‚ÄĚ
d
Thanks. I tried out SingleTask. In the case where my app isn't running, it successfully fires it up as a standalone task. For the case where my app is already running, it just brings my app to the forefront. This is an issue because it ignores the data of the intent, which I need. Any way to get the standalone, but still act on the data in the intent?
u
Have you tried to override onNewIntent method
d
I have. I'm still trying to figure out what triggers a call to it.
Thanks guys. I have a working solution now using SingleTask as well as onNewIntent.