从谷歌地图URL打开应用程序

时间:2012-10-05 11:24:36

标签: android android-intent

您好,从URL打开应用程序我有以下代码

                                                           

        <intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:host="maps.google.com" android:scheme="http"></data>
        </intent-filter>

网址在

之下
   https://maps.google.com/maps?q=70.005540,-111.000050

以及获取以下活动中的数据是我的代码

   Uri data = getIntent().getData();
        if (data != null) {
            txtView.setText(data.getPath());
        }

我的问题是,当我点击上面的URL时,我的应用程序没有打开....

2 个答案:

答案 0 :(得分:1)

用以下代码替换xml代码

   <intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:host="maps.google.com" android:scheme="https"></data>
        </intent-filter>

它会起作用,我已经测试了

答案 1 :(得分:0)

尝试使用此功能以打开网页视图中的链接。

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
相关问题