2017-10-04 117 views
-1

我已經嘗試了幾件事情,我發現在搜索和似乎沒有任何工作的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瀏覽器中的鏈接(帶有或不帶尾部斜線)。鏈接在瀏覽器中打開,而不是在應用程序中打開。

+0

請加滿清單請 – Cliff

+0

@Cliff上面添加 –

回答

2

添加下面的固定問題:

<data android:pathPattern="/.*"></data>

我希望這將是幫助您

0

首先,你可以在你的ADB這個命令來測試它

adb shell am start 
    -W -a android.intent.action.VIEW 
    -d "https://example.com" *YOUR PACKAGE* 
您的第二個DeepLink刪除(android:pathPrefix =「」)

<data android:scheme="https" android:host="example.com" /> 

確保意圖過濾器是活動標籤內,像這樣:

<activity 
     android:name=".activities.ParseDeepLinkActivity" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 

      <data 
       android:host="deeplink" 
       android:scheme="wizzo" /> 

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

     </intent-filter> 
    </activity> 

編輯:

請刪除:

android:label="@string/app_name" android:autoVerify="true" 
+0

我試着用''並且沒有運氣。我確實在活動標籤內有意圖過濾器。我用完整的清單編輯了問題。 –

+0

你用命令行嘗試過嗎? – Cliff

+0

通過命令行我得到這個錯誤:'錯誤:活動未開始,無法解決Intent {act = android.intent.action.VIEW dat = https://example.com/... flg = 0x10000000 pkg = com .example launchParam = MultiScreenLaunchParams {mDisplayId = 0 mFlags = 0}}' –