我正在尝试编写一个应用程序,您可以在其中输入地址,然后您将被重定向到谷歌地图。 (我想这就是所谓的隐含 Intent )
-我已经创建了启动主要 Activity 的 Intent ,这是我的应用程序中的唯一 Activity 。 Main Activity 由一些文本、一个编辑字段和一个按钮组成。
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
}
}
最佳答案
如果您在模拟器中对此进行测试,则情况与在设备中有所不同。
当您创建 Android 虚拟设备时,您应该选择 Google API 作为目标。如果你没有安装它们,你可以使用 SDK Manager 下载它。
看看this .
关于android content activitynotfoundexception 没有找到处理 Intent 的 Activity - 当试图去 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11525666/