-1

I need to open my application when clicked the URL Link in E-mail, Message or Browser applications. So, see the my code for this feature:

<activity
    android:name=".ui.main.MainActivity"
    android:configChanges="orientation"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="https" android:host="www.mysite.org"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.APP_EMAIL"/>
        <category android:name="android.intent.category.APP_MESSAGING"/>
        <category android:name="android.intent.category.APP_BROWSER"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

This code is sufficient and works on some mobile devices, especially devices with android versions 5.0, 6.0 and 7.0 but does not work on versions 7.1 and 8.0. Why does this happen? Is it a permission problem?

Tiago Barreto
  • 822
  • 13
  • 31

2 Answers2

2

Ex: Your url will be something like https://example.com and you have the intent filter in Android Manifest as below:

<activity
    android:name="com.droid.MainActivity"
    android:label="@string/app_name" >

    <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:scheme="https" />
    </intent-filter>
</activity>

Use the URL Mapping editor to easily add URL intent filters to your Activities with Android App Links (Android Studio > Tools > Android App Links).

Tiago Barreto
  • 822
  • 13
  • 31
Nirav Joshi
  • 1,713
  • 15
  • 28
1

After reading changes in Android O I came to the conclusion that the problem is described as follows

URIs cannot contain empty labels. Previously, the platform supported a workaround to accept empty labels in host names, which is an illegal use of URIs. This workaround was for compatibility with older libcore releases. Developers using the API incorrectly would see an ADB message: "URI example..com has empty labels in the hostname. This is malformed and will not be accepted in future Android releases." Android 8.0 removes this workaround; the system returns null for malformed URIs.

So try adding android:label="string resource" to your intent-filter syntax so the user will see it in the alternatives menu.

Rainmaker
  • 10,294
  • 9
  • 54
  • 89