更新:显然这没有任何改变。不知道为什么以前没用。
我正在关注Android文档中的示例,但我无法获得深层链接。当我尝试从adb启动时出现以下错误:
$ adb shell am start -a android.intent.action.VIEW -d "example://gizmos" com.example.deeplink
Starting: Intent { act=android.intent.action.VIEW dat="example://gizmos" pkg=com.example.deeplink }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat="example://gizmos" flg=0x10000000 pkg=com.example.deeplink }
这是清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.deeplink" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.deeplink.GizmosActivity" android:label="@string/app_name" >
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="example" android:host="gizmos" />
</intent-filter>
</activity>
</application>
</manifest>
不是它会启动,但这就是我在GizmosActivity中所拥有的:
package com.example.deeplink;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
public class GizmosActivity extends Activity {
public static String TAG = "debug";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
Log.v(TAG,action+" "+data.toString());
}
}
完整项目在这里:https://github.com/tomkincaid/Deep-Link
我做错了什么?