【发布时间】:2010-12-18 21:51:42
【问题描述】:
我正在开发一个 android 应用程序,我希望在我打开设备时自动调用我的应用程序。所以我在应用程序的 manifest.xml 文件中使用了此权限<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />,我使用了服务、活动和注册广播接收器在 manifest.xml 文件中。但是我在何时启动我的设备时出现了排除错误。如何解决这个问题。
我的接收方代码如下
context.startActivity(new Intent(context,ServicesDemo.class));
//在myReceiver的mainfest.xml中
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter> </receiver>
我收到了这个异常java.lang.RuntimeException: Unable to start receiver com.servicedemo.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
【问题讨论】:
-
@thanks cxOder,我发布了 logcat
标签: android