我已經嘗試了幾件事情,我發現在搜索和似乎沒有任何工作的http或https網址。我現在在AndroidManifest.xml中使用下面的代碼。Android的意圖過濾器與HTTP/HTTPS不工作
<intent-filter android:label="@string/app_name" android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="example" android:host="item" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/somepage" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/somepage/" />
</intent-filter>
例如:// item可以啓動我的應用程序。 https://example.com不起作用,它只是在瀏覽器中打開頁面。我試圖將每個數據標籤分成不同的意圖過濾器,但它仍然不起作用。任何幫助將非常感激。
編輯: 完整清單:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="***"
android:versionCode="1"
android:versionName="1.0"
>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:largeHeap="true">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="@string/app_name" android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="example" android:host="item" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/somepage" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/somepage/" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
編輯2: 我發現,意圖作品(在應用程序打開),如果我通過命令行運行以下命令: adb shell am start -W -a android.intent.action.VIEW -d "https://example.com/" *package*
和拖尾的斜槓是必需的。如果沒有斜線,它不起作用。 但是,在應用程序中未打開android chrome瀏覽器中的鏈接(帶有或不帶尾部斜線)。鏈接在瀏覽器中打開,而不是在應用程序中打開。
請加滿清單請 – Cliff
@Cliff上面添加 –