BroadcastReceiver的尝试将无序播放过程中返回结果 - PACKAGE_ADDED在Android中 [英] BroadcastReceiver trying to return result during a non-ordered broadcast - PACKAGE_ADDED in Android

查看:317
本文介绍了BroadcastReceiver的尝试将无序播放过程中返回结果 - PACKAGE_ADDED在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此异常在我下面给出code。我没有任何想法是不对的code。请帮我摆脱这种异常。

  05-23 23:33:49.853:E / BroadcastReceiver的(26895):BroadcastReceiver的尝试将无序播放过程中返回结果
05-23 23:33:49.853:E / BroadcastReceiver的(26895):java.lang.RuntimeException的:BroadcastReceiver的尝试将无序播放过程中返回结果
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.content.BroadcastReceiver.checkSynchronousHint(BroadcastReceiver.java:783)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.content.BroadcastReceiver.setResult code(BroadcastReceiver.java:549)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在com.waypedia.rupesh.abhi.RetentionApplicationAddedBroadcastReceiver.onReceive(RetentionApplicationAddedBroadcastReceiver.java:18)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.app.ActivityThread.handleReceiver(ActivityThread.java:2446)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.app.ActivityThread.access $ 1700(ActivityThread.java:139)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1286)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.os.Handler.dispatchMessage(Handler.java:102)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.os.Looper.loop(Looper.java:136)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在android.app.ActivityThread.main(ActivityThread.java:5102)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在java.lang.reflect.Method.invokeNative(本机方法)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在java.lang.reflect.Method.invoke(Method.java:515)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:785)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-23 23:33:49.853:E / BroadcastReceiver的(26895):在dalvik.system.NativeStart.main(本机方法)
 

下面是我的code:

 公共类RetentionApplicationAddedBroadcastReceiver扩展WakefulBroadcastReceiver {
    @覆盖
公共无效的onReceive(上下文的背景下,意图意图){

    组件名补偿=新的组件名(context.getPackageName()
            RetentionAddIntentService.class.getName());
    //启动服务,保持设备时推出清醒。
    startWakefulService(上下文,(intent.setComponent(化合物)));
    的setResult code(Activity.RESULT_OK); // ** 18行**
}
 

解决方案

删除的setResult code()。这只是用于与一个有序的广播使用,如在<一个描述href="http://developer.android.com/reference/android/content/BroadcastReceiver.html#setResult$c$c%28int%29">the C $ C文档的的setResult $()

I am getting this exception in my below given code. i don't have any idea what is wrong with this code. Please help me out to get rid of this exception.

05-23 23:33:49.853: E/BroadcastReceiver(26895): BroadcastReceiver trying to return result during a non-ordered broadcast
05-23 23:33:49.853: E/BroadcastReceiver(26895): java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.content.BroadcastReceiver.checkSynchronousHint(BroadcastReceiver.java:783)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.content.BroadcastReceiver.setResultCode(BroadcastReceiver.java:549)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at com.waypedia.rupesh.abhi.RetentionApplicationAddedBroadcastReceiver.onReceive(RetentionApplicationAddedBroadcastReceiver.java:18)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2446)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.app.ActivityThread.access$1700(ActivityThread.java:139)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.os.Looper.loop(Looper.java:136)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at android.app.ActivityThread.main(ActivityThread.java:5102)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at java.lang.reflect.Method.invokeNative(Native Method)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at java.lang.reflect.Method.invoke(Method.java:515)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-23 23:33:49.853: E/BroadcastReceiver(26895):     at dalvik.system.NativeStart.main(Native Method)

Below is my code:

    public class RetentionApplicationAddedBroadcastReceiver extends WakefulBroadcastReceiver {
    @Override
public void onReceive(Context context, Intent intent) {

    ComponentName comp = new ComponentName(context.getPackageName(),
            RetentionAddIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK); //**LINE 18**
}

解决方案

Delete setResultCode(). That is only for use with an ordered broadcast, as is described in the documentation for setResultCode().

这篇关于BroadcastReceiver的尝试将无序播放过程中返回结果 - PACKAGE_ADDED在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆