- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个非常简单的自定义 Intent 示例。我已经搜索过这个错误,但没有一个论坛有适合我的答案。这是我的文件:
public class DemoImplicit extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void whenButtonIsClicked(View view) {
Intent intent = new Intent("com.example.action.NEW_ACTION"); //<<<<<<<
intent.addCategory("android.intent.category.DEFAULT"); //<<<<<<<
// Intent intent = new Intent("android.intent.action.VIEW");
// intent.addCategory("com.example.MY_CATEGORY");
startActivity(intent); //<<<<<<<
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demos" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SatisfyIntent" android:label="@string/app_name">
<intent-filter>
<!-- action android:name="android.intent.action.VIEW" / -->
<!-- category android:name="com.example.MY_CATEGORY" / -->
<action android:name="com.example.action.NEW_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
这两个单独的文件位于两个不同的 Eclipse 项目中,但我确保在将包含 startActivity 调用的文件加载到模拟器之前将包含 intent-filter 的项目加载到模拟器。无论如何,我总是得到一个 ActivityNotFoundException。我做错了什么?
附言这是包含 DemoImplicit.java 的项目的 AndroidManifest.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demos"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".DemoImplicit"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
最佳答案
首先你应该确保你的AndroidManifest.xml
文件必须定义了 DemoImplicit
这方面的 Activity 。
像这样:<activity android:name=".DemoImplicit"/>
还在您的代码中指定了 SatisfyIntent
作为启动器 Activity
<activity android:name=".SatisfyIntent" android:label="@string/app_name">
但是在这里,您的 Java 代码中似乎没有类似的东西。
所以底线是:Activity
你想运行的必须在你的 AndroidManifest.xml
中定义文件。
关于安卓 ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4911694/
我是 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 。 这是
我是一名优秀的程序员,十分优秀!