I have been working on an android application which uses google maps it is map related application. i want my to be able to handle implicit intents like if user click on map link like Latitude and longitude my app should handle the intent and show that position on map. Like default Google Maps Application. Is it possible then what piece of code for intent specific activity?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Add an intent-filter
in the Manifest
so your app can respond to map URLs:
<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:scheme="http" android:host="maps.google.com" />
<data android:scheme="https" android:host="maps.google.com" />
<data android:scheme="geo"/>
</intent-filter>
Once in your app, you can retrieve the URI using this code:
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Uri data = intent.getData(); // Here you will receive the URI
// ...
}