为地图意图制作自己的Android应用程序默认值 [英] Making own Android App default for map intents

查看:200
本文介绍了为地图意图制作自己的Android应用程序默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究一个使用谷歌地图的Android应用程序,它是与地图相关的应用程序。我希望我能够处理隐式意图,如用户点击地图链接(如纬度和经度),我的应用程序应处理该意图并在地图上显示该位置。像默认的Google地图应用程序。是否有可能为意向特定的活动做了哪些代码? 解决方案

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

 << ;意图滤光器> 
< category android:name =android.intent.category.DEFAULT/>
< category android:name =android.intent.category.BROWSABLE/>
< data android:scheme =httpandroid:host =maps.google.com/>
< data android:scheme =httpsandroid:host =maps.google.com/>
< data android:scheme =geo/>
< / intent-filter>

在您的应用程序中,您可以使用以下代码检索URI:

  protected void onCreate(Bundle savedInstanceState){
Intent intent = getIntent();
Uri data = intent.getData(); //这里您将收到URI

// ...
}


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?

解决方案

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

    // ...
}

这篇关于为地图意图制作自己的Android应用程序默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆