【问题标题】:links from the browser to open my Android app [duplicate]来自浏览器的链接以打开我的 Android 应用程序 [重复]
【发布时间】:2013-05-13 11:24:22
【问题描述】:

当用户单击给定模式的 URL 而不是允许浏览器打开它时,我希望能够启动已安装的应用程序。这可能是当用户在浏览器中的网页上时。

例如,从手机中的任意位置点击 YouTube 链接,您就有机会打开之前安装的 YouTube 应用

如何为我自己的应用实现这一点?

【问题讨论】:

    标签: android android-layout android-intent android-emulator android-webview


    【解决方案1】:

    在您的 MyLinkActivity 中:

    String url = getIntent().getDataString();
    

    在您的清单中:

    <activity
        android:name=".MyLinkActivity">
        <intent-filter>
            <data
                android:host="*.myurl.com"
                android:scheme="http" />
            <data
                android:host="myurl.com"
                android:scheme="http" />
            <data
                android:host="*.myurl.com"
                android:scheme="https" />
            <data
                android:host="myurl.com"
                android:scheme="https" />
                    
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <action android:name="android.intent.action.VIEW" />   
        </intent-filter>
    </activity>
    

    【讨论】:

    • 对我不起作用:/
    猜你喜欢
    • 2010-12-09
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 2015-12-02
    • 2018-08-10
    相关资源
    最近更新 更多