目前我有两个网页,home
和about
。 about
是其中的深层链接,因此当我单击该链接时,android 为我提供了使用浏览器或我自己的应用程序打开该链接的选项。我想在我的应用程序中明确打开该链接。我不希望应用程序列表来处理它。 这可能吗?下面是我的代码:
AndroidManifest.xml
<activity
android:name=".AboutPage"
android:label="@string/about_page">
<intent-filter android:label="@string/filter_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="http"
android:host="appindexing.robscv.info"
android:pathPrefix="@string/aboutHTML"/>
</intent-filter>
</activity>
关于页面.java
public class AboutPage extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.about_page);
// Enable the "Up" button for more navigation options
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
onNewIntent(getIntent());
}
protected void onNewIntent(Intent intent){
String action = intent.getAction();
String data = intent.getDataString();
Log.d(action, data);
}
}
最佳答案
简而言之。 否
但是
它来了。 这是计划在 Android M 中发布的功能.
你所要做的就是将它添加到 list 中
<intent-filter android:label="@string/filter_name" android:autoVerify="true">
//...categories etc
</intent-filter>
更多信息 here
仅供引用,这实际上是直接深度链接到应用程序,如果用户手机上有多个应用程序autoVerify
,那么它会抛出提示。
关于使用显式 Intent 的 Android 深度链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31291430/