Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app no longer usable after declaring browsable category

While developing a very simple application I stumbled upon this strange behaviour when declaring the following lines to my AndroidManifest.xml:

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


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

Basically people can install the APK but the app disappears from the menu and can't be started anymore. Via Settings > Applications you can see that the app is installed.

So I've created a basic testcase, just a webview app with only one activity which loads the webview. Published it to the app store, as expected no problems. Pushed an update with the intent category, and same problem arrises. I can update to this newer version, but the app is removed from the home/app screen so it can't be launched.

Complete Manifestfile:

<?xml version="1.0" encoding="utf-8"?>
      <manifest package="com.example.appname"
      xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>

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


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

        </intent-filter>
    </activity>
</application>

The app runs fine when installed in emulator, or via ADB on device. The browsable declaration works fine.

like image 345
Analogue Avatar asked Oct 25 '25 21:10

Analogue


1 Answers

You can declare different intent-filter for different actions.

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

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

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="www.example.com" android:pathPrefix="/prefix" />
    </intent-filter>

</activity>
like image 85
Sanjeet Avatar answered Oct 27 '25 14:10

Sanjeet