Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You must use the http and https protocols for intent filters. Why receive this error message?

When I choosing to upload android Instant App apk-s zip to Google Play Developer Console I receive this error: Upload failed. You must use the http and https protocols for intent filters

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.example.feature">

<application>
    <meta-data
        android:name="asset_statements"
        android:resource="@string/asset_statements"/>
    <activity android:name=".ui.MainActivity">
        <tools:validation testUrl="https://com.example/"/>

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

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter
            android:order="1"
            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="https"
                android:host="com.example"
                android:pathPattern="/.*"/>
        </intent-filter>

        <meta-data
            android:name="default-url"
            android:value="https://com.example"/>
    </activity>
</application>

like image 374
Hayk Avatar asked Jul 12 '17 12:07

Hayk


People also ask

What is the purpose of the intent filter?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.

What's the difference between intent and intent filters?

An intent is an object that can hold the os or other app activity and its data in uri form.It is started using startActivity(intent-obj).. \n whereas IntentFilter can fetch activity information on os or other app activities.

What is the specific role of intent receiver and intent filter in broadcast receiver class?

An intent-filter determines which action should be received. To create a BroadcastReceiver, you have to extend the BroadcastReceiver class and override onReceive(Context,Intent) method. Here you can check the incoming intent with Intent. getAction() and execute code accordingly.

What are intents and what is the purpose of using intents?

An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver,start services and send message between two activities.


3 Answers

I was having this problem until I changed my AndroidManifest to this way

<activity android:name=".MainActivity"> 
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter 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:host="example.com" />
         <data android:scheme="http" />
         <data android:scheme="https" />
         <data android:pathPattern="/InstantApp" />
    </intent-filter>
</activity>
like image 79
Bruno A. Klein Avatar answered Oct 06 '22 19:10

Bruno A. Klein


Make sure your intent-filter has at least the following attributes. Both "http" and "https" scheme must be present at the same time:

         <intent-filter
            android:autoVerify="true"
            android:order="1">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="abc.com" />
            <data android:pathPattern="/def" />
            <data android:scheme="https" />
            <data android:scheme="http" />
        </intent-filter>
like image 33
chauduyphanvu Avatar answered Oct 06 '22 20:10

chauduyphanvu


I was using intent-filter to receive dynamic link but also was integrating deep link in navigation graph, for this reason it was also necessary to include "http" and "https" support in the nav_graph.xml document.

<fragment
        android:id="@+id/someFragment"
        android:name="com.apps.example.SomeFragment"
        android:label="fragment_some"
        tools:layout="@layout/fragment_some" >
        <deepLink
            android:id="@+id/deepLink1"
            app:uri="https://example.page.link" />

        <deepLink
            android:id="@+id/deepLink2"
            app:uri="http://example.page.link" />
  </fragment>
like image 36
Juan David Velasquez Avatar answered Oct 06 '22 18:10

Juan David Velasquez