- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
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);
}
最佳答案
我认为您的问题是没有用于处理 Intent.ACTION_VIEW 和 Intent.ACTION_WEB_SEARCH 操作的 Activity ,要检查是否有用于处理您的 Intent 的 Activity ,您可以先检查一下:
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
如果 activities 列表中的 Activity 数量为 0,这意味着目前没有用于处理您的 Intent 的 Activity,在尝试启动 Activity 之前,您应该首先检查它..
编辑:据我们所知,这些操作对于 Android 设备( map 和 Web 浏览器)是通用的,因此您应该检查您传递的 URI 是否正确。
关于java - 安卓:ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16778300/
我是 android 和 java 编程的新手,我在我的应用程序中收到 ActivityNotFoundException。 这里是 Activity 被调用的仅有的两次: public void o
我正在使用 contacl 列表数据库应用程序,当我点击调用应用程序时,应用程序正在运行,但是当我点击列表中的发送电子邮件时,我收到以下错误: FATAL EXCEPTION: main an
我正在尝试创建一个非常简单的自定义 Intent 示例。我已经搜索过这个错误,但没有一个论坛有适合我的答案。这是我的文件: public class DemoImplicit extends Acti
我在以下代码中收到 ActivityNotFoundException: Main.java Intent intent = new Intent(); intent.setAction("
我想开始这样的 Activity : Intent intent = new Intent(this, FeedbackActivity.class); activity.startActivity(
对于存在并包含在我的应用程序 AndroidManifest.xml 中的 Activity ,我收到 ActivityNotFoundException。 这是我的场景: 我的应用程序项目包是:co
有时,当我尝试在应用程序中打开浏览器进行添加时,我的应用程序会崩溃,这是我的代码: public void onBannerClick(final View view){ Intent intent
首先,我使用的是 Eclipse IDE。我正在尝试制作一个应用程序商店。我不知道发生了什么,但它以前有效,现在我在 LogCat 中收到此错误。 02-02 13:26:39.750: E/Andr
此问题适用于显示网站图像和描述的应用程序,当单击 ListView 时,与该描述相关联的网站会在浏览器中打开。 但是当我点击其中一个时出现错误。我不知道如何解决它,我们将不胜感激。 这是错误堆栈: E
我正在向这样的广播接收器发送 Intent 。 Intent cpIntent = new Intent(); cpIntent.setClassName("com.android.contacts"
我正在使用出色的 ACRA 库来报告用户在我的应用测试版中遇到的任何错误。到目前为止,它显示的是一些用户在发送彩信时遇到问题,而大多数用户则没有。 特别是我发现使用 Droid Bionic 设备的用
我已经有几年没有做过异常处理了,我似乎无法弄清楚我做错了什么。我有一个应用程序可以打开我的另一个应用程序,如果用户还没有其他应用程序,我希望当前应用程序重定向到 Play 商店。现在,如果未安装该应用
我注意到分析标记了一些错误: class android.content.ActivityNotFoundException Msg: android.app.Instrumentation.chec
在我的应用中,我需要使用startActivity来查看文件的内容,或者使用默认的应用程序来打开某个文件,但有时android系统可能没有安装需要的应用程序。 我的问题是如何处理这个异常。我想要干杯,
我编写了一段代码,允许用户通过电子邮件发送订单给供应商 [ShopOwner] 以及他们的个人和购物车商品详细信息,但在这里我得到了一个 错误:不幸的是应用已停止 Logcat: 01-30 17:5
public void onContacts(View v) { Intent i=new Intent(Intent.ACTION_VIEW, ContactsContract.Contac
我在尝试启动服务时遇到“找不到 Activity ”异常。我在 list 中注册了服务。添加我认为是相关代码和 LogCat。让我知道您是否需要查看更多内容。 01-29 17:41:51.440
我在尝试从另一个 Activity 中调用 Activity 时遇到此异常。完整的异常(exception)是 android.content.ActivityNotFoundException:Un
我正在使用 Android Studio 中的产品风格,并且遇到了一个问题......! 我在 build.gradle 文件中设置了两种产品风格 产品 flavor { pro {
我有这个链接代表 Reddit 上的一个子项目。我正在尝试使用自定义 intent-filter当用户单击链接时启动加载子项(例如 reddit.com/r/test )的 Activity 。 这是
我是一名优秀的程序员,十分优秀!