public void onContacts(View v)
{
Intent i=new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI);
startActivity(i);
}
public void onBrowse(View v)
{
String s1= et1.getText().toString();
Intent i= new Intent(Intent.ACTION_VIEW, Uri.parse(s1));
startActivity(i);
}
public void onSearch(View v)
{
String s1= et2.getText().toString();
Intent i=new Intent(Intent.ACTION_WEB_SEARCH);
i.putExtra(SearchManager.QUERY, s1);
startActivity(i);
}
public void onMap(View v)
{
String s1= et3.getText().toString();
Intent i=new Intent(Intent.ACTION_VIEW,Uri.parse("geo:0,0?q="+s1));
startActivity(i);
}这是几个方法,每个方法都附加在各自的按钮上,单击这些按钮中的任何一个都会显示ActivityNotFoundException,除了没有附加到任何编辑文本的onContacts()方法.
logcat结果
05-27 23:18:42.984: E/AndroidRuntime(714): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google }AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AllIntent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".AllIntentActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
看看能不能帮上忙..。我运行了一个具有相同函数的程序,其中没有从编辑文本中检索字符串,即在它的框架方法中提供所需的资源。
我说的那个的源代码
public void onContents(View v)
{
Intent i=new Intent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);
startActivity(i);
}
public void onBrowser(View v)
{
Intent i= new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(i);
}
public void onSearch(View v)
{
Intent i=new Intent(Intent.ACTION_WEB_SEARCH);
i.putExtra(SearchManager.QUERY, "tapu");
startActivity(i);
}
public void onMap(View v)
{
Intent i=new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=hyderabad"));
startActivity(i);
}
public void onCall(View v)
{
Intent i=new Intent(Intent.ACTION_CALL,Uri.parse("tel:9776215312"));
startActivity(i);
}发布于 2013-05-27 18:20:45
我认为您的问题是,没有处理Intent.ACTION_VIEW和Intent.ACTION_WEB_SEARCH操作的活动,要检查是否有处理您的意图的活动,可以在此之前检查以下内容:
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;如果列表 Activity 中的活动数为0,这意味着此时还没有处理您的意图的活动,那么在尝试开始某个活动之前,您应该先检查一下。
编辑:正如我们所知,这些操作对于android设备(地图和web浏览器)来说是常见的,因此您应该检查您正在执行的URI是否正确。
发布于 2013-05-27 18:37:24
您的意图URI是错误的。或者更确切地说,TextView的内容不是以打开您所期望的搜索对话框的方式构造的。例如,尝试输入:
google.com/search?q=blah作为您在TextView中的文本
https://stackoverflow.com/questions/16778300
复制相似问题