问题描述
https://myapp.domain.com/#/view/abc
其中只有 abc 是改变的参数并且是我需要应用程序作为参数的那个。
我试过了,但没用
<data
android:host="myapp.domain.com"
android:pathPrefix="/#/view"
android:scheme="https" />
<data
android:host="myapp.domain.com"
android:pathPrefix="/#/view"
android:scheme="http" />
<data
android:host="myapp.domain.com"
android:pathPrefix="/#/view"
android:scheme="app" />
解决方法
在清单文件中的活动标签中试试这个
<intent-filter android:label="Example">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="myapp.domain.com"
android:pathPrefix="/#" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
Activity.java 内部
Uri uri = getIntent().getData();
if(uri != null){
List<String> segments = uri.getPathSegments();
Log.e(TAG,"onCreate: "+segments );
Log.e(TAG,"onCreate: "+segments.get((segments.size()-1)) );
}
,
经过努力,我使用了这个:
<data android:scheme="https"
android:host="myapp.domain.com"
android:pathPrefix="/" />
在我的活动中:
String id = data.toString().replaceAll(".*/","");
注意:我不能使用 uri.getPathSegments(); 因为它返回我的空列表。