Bri*_*ian 4 android deep-linking android-manifest android-intent
我正在尝试启用深层链接,以便某些链接启动我的应用程序。
我读了这个教程https://developer.android.com/training/app-indexing/deep-linking.html并非常接近它,但是当我尝试使用adb将VIEW意图发送到该应用程序进行测试时,我只是得到错误
Error: Activity not started, unable to resolve Intent { act=android.intent.actio
n.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp.DeepLinkActivity }
Run Code Online (Sandbox Code Playgroud)
DeepLinkActivity.java
public class DeepLinkActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getAction() == Intent.ACTION_VIEW) {
Uri uri = getIntent().getData();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Android Manifest宣布Deeplink活动
<activity android:name="com.myapp.DeepLinkActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="gizmos"
android:scheme="example" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="www.example.com"
android:pathPrefix="gizmos"
android:scheme="http" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
ADB命令发送视图意图
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp.DeepLinkActivity
Run Code Online (Sandbox Code Playgroud)
但我认为我甚至不需要完整的活动路径
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp
Run Code Online (Sandbox Code Playgroud)
尝试完全跳过软件包参数。我有完全相同的问题,它可以工作。
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos"
归档时间: |
|
查看次数: |
5582 次 |
最近记录: |