I read in so many places that the problem is related to the manifest and the definition of the first activity. It seems that I'm doing fine but still the open button, after installing the APK, is disabled and I don't see the icon on the device
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"/>
</intent-filter>
</activity>
<activity android:name=".DateSelectorActivity"
android:label="@string/app_name">
</activity>
</application>
Your problem is this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"/>
</intent-filter>
Here, you are saying that this activity will only be launched if:
Intent
has an action of MAIN
or VIEW
, and
Intent
has the categories of LAUNCHER
or BROWSABLE
, and
Intent
has a Uri
with a scheme of http
and a host of www.example.com
The home screen launcher and Settings app will not be creating such an Intent
, and so they cannot launch this activity.
Either:
VIEW
, BROWSABLE
, and <data>
portions of what you have, orMove those into a separate <intent-filter>
:
<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"/>
</intent-filter>
Multiple <intent-filter>
elements represent an OR
operation: an Intent
that matches the first filter or the second filter will work for this activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With