使用显式 Intent 的 Android 深度链接

标签 android

目前我有两个网页,homeaboutabout 是其中的深层链接,因此当我单击该链接时,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/

相关文章:

Android 带抽屉的 Google 搜索栏

android - 如何在 Jetpack Compose 中正确使用 StateFlow?

android - 动态添加的行不可见

android - 应用程序 :elevation ="0dp" hide layout inside toolbar

Android Activity 生命周期 - 通知服务

android - 违反设备和网络滥用政策

android - 这样我就可以在 Intent 中发送 Toast 了吗?

java - 在 android/java 应用程序中测试加密功能性能(及时测量)的最佳方法?

android - 我可以从我的 Cordova config.xml 控制 AndroidManifest.xml 文件的 <supports-screen> 设置吗?

android - 对位图使用 5x5 颜色矩阵