Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Chrome浏览器中单击href时启动Android活动_Android_Intentfilter - Fatal编程技术网

在Chrome浏览器中单击href时启动Android活动

在Chrome浏览器中单击href时启动Android活动,android,intentfilter,Android,Intentfilter,我想在Chrome浏览器应用程序中的某个web中单击时打开我的应用程序的登录活动。我有此代码,但它不起作用: <activity android:label="@string/app_name" android:launchMode="singleTask" android:name=".activities.LoginActivity" android:screenOrientation="portrait"

我想在Chrome浏览器应用程序中的某个web中单击
时打开我的应用程序的登录活动。我有此代码,但它不起作用:

    <activity android:label="@string/app_name" android:launchMode="singleTask"
                          android:name=".activities.LoginActivity" android:screenOrientation="portrait"
                          android:windowSoftInputMode="stateVisible">  
      <intent-filter>
          <action android:name="android.intent.action.MAIN"/>
          <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      <intent-filter>
          <data android:scheme="http" android:host="myhost.com"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <action android:name="android.intent.action.VIEW"/>
      </intent-filter>
   </activity>

我做错了什么


谢谢。

您需要这样设置:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
    <data
        android:host="www.example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
</intent-filter>

注意,在您的例子中,您需要使用android:pathPrefix而不是android:path