2017-03-02 88 views
2
Android deep linking is not working 
=================================== 
Android link:-notification://id=notificationid 

1: - 在清单Android的深层链接无法正常工作

 <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

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

        <data 
         android:host="id" 
         android:scheme="notification" /> 
       </intent-filter>  

2: - 和编码侧

@Override 
     protected void onResume() { 
      super.onResume();   
      Intent intent = getIntent(); 
      String string=intent.getAction(); 
      Uri data = intent.getData(); 
      Log.d("hello","cgbdsuyfdkv"); 
     } 

,但它不工作,请任何机构可以帮助我! !

+0

是您的代码第一次运行? –

+0

是运行我的代码和我的网址这样(通知:// id = notificationid)但它可以不能工作 –

+0

但第二次你无法获得更新通知ID?右 –

回答

0

你可以简单地修改网址

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. 
  1. 清单代码

      <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>  
    

2 .java代码#请在此处注册您的通知ID

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); 
    } 
+0

是的,我同意 我的Android链接: - **通知:// id = notificationid **不正确。 当我更改网址**通知://主机名?id = notificationid ** 其工作正常 –

0

我想你意图过滤器是不完整的

<!-- 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> 
0

第一步:

<intent-filter> 
    <data android:scheme="your_uri_scheme" /> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
</intent-filter> 

第2步:

Uri data = this.getIntent().getData(); 
if (data != null && data.isHierarchical()) { 
    String uri = this.getIntent().getDataString(); 
    Log.i("MyApp", "Deep link clicked " + uri); 
} 
0

添加onNewIntent()方法您Activity,然后使用意向对象,在OnNewintent()方法中是可变的,其具有更新特德方法。

onNewIntent()旨在为切入点,对于已经在堆栈上运行的其他地方,因此不能称之为onCreate()singleTopsingleTask活动。从活动生命周期角度来看,因此需要在onNewIntent()之前致电onPause()。我建议你重写你的活动,不要在onNewIntent()中使用这些听众。例如大部分的时间我onNewIntent()方法仅是这样的:

@Override 
protected void onNewIntent(Intent intent) { 
    super.onNewIntent(intent); 
//use this intent object to get notificationid for second time 

}