为地图意图制作自己的Android App默认设置

时间:2016-06-30 06:45:12

标签: android google-maps android-intent google-maps-api-3 intentfilter

我一直在研究一个使用谷歌地图的android应用程序它是地图相关的应用程序。我希望我能够处理隐含的意图,如果用户点击像谷歌纵横和经度这样的地图链接我的应用程序应该处理意图并在地图上显示该位置。像默认的Google地图应用程序。那么针对特定目标活动的代码是否可能?

1 个答案:

答案 0 :(得分:0)

Manifest中添加intent-filter,以便您的应用可以回复地图网址:

<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>

进入您的应用后,您可以使用以下代码检索URI:

protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();  
    Uri data = intent.getData(); // Here you will receive the URI

    // ...
}