android内容activitynotfoundexception没有找到处理意图的活动 - 当试图去url时

时间:2012-07-17 15:20:49

标签: android android-intent

我正在尝试编写一个应用程序,您可以在其中输入地址,然后重定向到谷歌地图。 (我想这被称为隐含意图)

- 我创建了一个启动主要活动的意图,这是我应用中唯一的活动。 主要活动包括一些文本,编辑字段和按钮。

的AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.where_do_you_live"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />

</manifest>

这是按钮的代码:

public void Button1Click(View view)
{       
    try
    {
        addressField=(EditText)findViewById(R.id.address);

        String address=addressField.getText().toString();
        address=address.replace(' ','+');
        Intent geoIntent=new Intent(android.content.Intent.ACTION_VIEW,
            Uri.parse("geo:0,0?q=" + address));
        startActivity(geoIntent);

    }

    catch(Exception e)
    {
        TextView tv=(TextView)findViewById(R.id.textView1);
        tv.setText(e.toString());
        //finding stuff

    }

}

1 个答案:

答案 0 :(得分:5)

如果您在模拟器中进行测试,则情况与设备不同。

在创建Android虚拟设备时,您应该选择Google API作为目标。如果您没有安装它们,可以使用SDK Manager下载它。

查看this

enter image description here

相关问题