I try to write an Activity as an alternative to google maps. It works perfect when calling it by an google-maps url:
<activity android:name="DataActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="maps.google.com" />
</intent-filter>
</activity>
But for some reason it does not shown up when starting an Intent with a "geo"-URI.
My Activity:
<activity android:name="DataActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="geo" android:host="*" />
</intent-filter>
</activity>
The Caller (This starts Google Maps without the option to start my App):
final String uri = "geo:" + lat + "," + lng;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
Intent filter is declared inside Manifest file for an Activity. Important Note: If you are using above code make sure below things are correct: icon: This is displayed as icon for activity. You can check or save png image of name icon in drawable folder.
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.
Most commonly, ACTION_SEND action sends URL of build-in Browser app. While sharing the data, Intent call createChooser() method which takes Intent object and specify the title of the chooser dialog. Intent. createChooser() method allows to display the chooser.
An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.
try with
<intent-filter android:priority="0">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="geo"/>
</intent-filter>
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