Android深度链接不起作用
1:-在舱单中Android深度链接不起作用,android,Android,1:-在舱单中 Android deep linking is not working =================================== Android link:-notification://id=notificationid 但它不工作请任何人都可以帮助我 我认为您的意图过滤器不完整 @Override protected void onResume() { super.onResume();
Android deep linking is not working
===================================
Android link:-notification://id=notificationid
但它不工作请任何人都可以帮助我 我认为您的意图过滤器不完整
@Override
protected void onResume() {
super.onResume();
Intent intent = getIntent();
String string=intent.getAction();
Uri data = intent.getData();
Log.d("hello","cgbdsuyfdkv");
}
第一步:
<!-- To open app using link -->
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="http"
android:host="yourdomain.com"
android:pathPrefix="/someurlparam">
</data>
</intent-filter>
将onNewIntent()
onNewIntent()
是作为singleTop
或singleTask
活动的入口点,这些活动已在堆栈中的其他位置运行,因此无法调用onCreate()
。因此,从活动生命周期的角度来看,需要在onNewIntent()之前调用onPause()
。我建议您重写活动,不要在onNewIntent()
中使用这些侦听器。例如,大多数情况下,我的onNewIntent()
方法就是这样的:
Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
String uri = this.getIntent().getDataString();
Log.i("MyApp", "Deep link clicked " + uri);
}
您只需修改url即可
清单代码
Android link:-notification://id=notificationid instead of
Android link:-notification://page?id=notificationid //page is host name
I tried a lot and find out this is working for me.
你的代码是第一次运行吗?是的,像这样运行我的代码和我的url(不是ification://id=notificationid)但是它不能工作,但是第二次你不能得到更新的通知id吗?是的,是的,我无法获得更新值。为什么请在下面检查我的答案?是的,我同意我的Android链接:-不是ification://id=notificationid 这是不对的。当我更改url时,不会ification://hostname?id=notificationid 工作正常
Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
String uri = this.getIntent().getDataString();
Log.i("MyApp", "Deep link clicked " + uri);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
//use this intent object to get notificationid for second time
}
Android link:-notification://id=notificationid instead of
Android link:-notification://page?id=notificationid //page is host name
I tried a lot and find out this is working for me.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="page"
android:scheme="notification" />
</intent-filter>
Intent intent = getIntent();
String string = intent.getAction();
Uri data = intent.getData();
if (data != null) {
String path = data.getPath();
String path1 = data.getPath();
providerUrl = intent.getData().toString();
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.parseUrl(providerUrl);
String id = sanitizer.getValue("id");
if (id != null)
Log.d("notification id", id);
}