我正在努力拥有像谷歌市场这样的内部链接的能力:
market://details?id=de.schildbach.oeffi
例如
myApplication://detail?id=11
如何更改清单或为应用程序创建其他能力?我想创建链接为myApplication://detail?id=11
并在其他Android应用程序(如Telegram或Whatsapp)中共享,用户可以在点击我创建的链接后转到我的应用程序。
答案 0 :(得分:1)
为您的活动添加一个意图过滤器:
<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="myApplication"
android:host="detail"
/>
</intent-filter>
然后处理活动的onCreate(..)或onNewIntent(..)
上的链接 Uri intentData = intent.getData();
if (intentData != null && "myApplication".equals(intentData.getHost()) && "detail".equals(intentData.getScheme()) {
//link was clicked, parse the rest of intent's data and do something useful
}
答案 1 :(得分:0)
你需要在你的Manifest中将“scheme”设置为你想要启动的活动的intent_filter之一,例如:
<data android:scheme="@string/deeplink_scheme" />
您可以在此处关注Android文档: Allowing Other Apps to Start Your Activity