错误接收广播意图问题 [英] Error Receiving Broadcast Intent Problem

查看:183
本文介绍了错误接收广播意图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的主要活动的广播接收器和发送广播意图后台服务。该应用程序每次我尝试运行它崩溃和日志显示以下错误消息:

I created a broadcast receiver in the main activity and the background service which is sending broadcast intents. The application crashes each time I try to run it and the Log displays the following error message:

13 10-04:30:43.218:
  ERROR / AndroidRuntime(695):
  了java.lang.RuntimeException:错误
  接收广播意向{
  行动= com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE
  (有临时演员)}中
  com.client.gaitlink.GaitLink$LoginStatusReceiver@431690e8

10-04 13:30:43.218: ERROR/AndroidRuntime(695): java.lang.RuntimeException: Error receiving broadcast Intent { action=com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE (has extras) } in com.client.gaitlink.GaitLink$LoginStatusReceiver@431690e8

该广播消息从CommunicationService类中的以下方法发送:

The broadcast message is sent from CommunicationService class in the following method:

private void announceLoginStatus(){
    Intent intent = new Intent(LOGIN_STATUS_UPDATE);
    intent.putExtra(SERVER_MESSAGE, mServerResponseMessage);
    intent.putExtra(SESSION_STRING, mSessionString);
    sendBroadcast(intent);
}

其中,

String LOGIN_STATUS_UPDATE = "com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE"

在主要活动如下广播reveiver定义:

in the main activity the following broadcast reveiver is defined:

public class LoginStatusReceiver extends BroadcastReceiver {

        public void onReceive(Context context, Intent intent) {
            String serverMessage = intent.getStringExtra(CommunicationService.SERVER_MESSAGE);
            String sessionString = intent.getStringExtra(CommunicationService.SESSION_STRING);

            userInfo.setSessionString(sessionString);
            saveSettings();
        }
    }

和在onResume方法进行注册:

and registered in onResume method:

        IntentFilter loginStatusFilter;
        loginStatusFilter = new IntentFilter(CommunicationService.LOGIN_STATUS_UPDATE);
        loginStatusReceiver = new LoginStatusReceiver();
        registerReceiver(loginStatusReceiver, loginStatusFilter);

和清单文件包含以下内容:

And the manifest file includes the following:

<activity android:name=".GaitLink"
              android:label="@string/app_name">
        <intent-filter>
            ...
            <action android:name="com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE" />
        </intent-filter>
    </activity>

我真的AP preciate如果有人可以解释为什么日志显示上述​​消息和应用程序崩溃。

I would really appreciate if anyone could explain why the Log displays the message above and the application crashes.

谢谢!

推荐答案

你去了一步在调试器中的步骤准确找到崩溃的发生位置?

Have you gone step by step in the debugger to find exactly where the crash occurs?

一件事看出来的是,如果你重写你正确地调用基类的构造函数任何Android生命周期事件时必要的。

One thing to look out for is if you are overriding any Android lifecycle events that you are properly calling the base class's constructor when necessary.

这篇关于错误接收广播意图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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