【问题标题】:Making own Android App default for map intents将自己的 Android 应用设为地图意图的默认设置
【发布时间】:2016-11-02 02:43:46
【问题描述】:

我一直在开发一个使用谷歌地图的安卓应用程序,它是与地图相关的应用程序。我希望我能够处理隐式意图,例如如果用户单击地图链接(如纬度和经度),我的应用程序应该处理意图并在地图上显示该位置。像默认的谷歌地图应用程序。那么有没有可能为特定的意图活动编写一段代码?

【问题讨论】:

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


    【解决方案1】:

    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
    
        // ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-01
      • 1970-01-01
      • 2013-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多