Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent-filter for GEO-URI

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)));
like image 920
Stahlkocher Avatar asked Dec 06 '10 17:12

Stahlkocher


People also ask

Where do you put the intent filter in manifest?

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.

What does the intent filter do in Android?

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 is the use of intent createChooser () method?

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.

What is intent filter example?

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.


1 Answers

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>
like image 122
GoranK Avatar answered Oct 16 '22 23:10

GoranK