About starting Android app from an URL

后端 未结 1 893
借酒劲吻你
借酒劲吻你 2020-12-05 11:48

I am trying to figure out how to start an app from a URL, and how I should write that URL.

I have the following code in my AndroidManifest:



        
相关标签:
1条回答
  • 2020-12-05 12:23

    You need to have two <intent-filter> elements for this <activity>. One will be for MAIN and LAUNCHER. The other will be for VIEW, BROWSABLE/DEFAULT, and your <data> element:

    <activity android:name=".MyActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"></action>
            <category android:name="android.intent.category.LAUNCHER"></category>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:host="my.app" android:scheme="http"></data>
        </intent-filter>
    </activity>
    

    Then, http://my.app should launch your activity.

    0 讨论(0)
提交回复
热议问题