下面是我的BroadcastReceiver
代码,我收到此错误:
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extra = intent.getExtras();
String username = extra.getString(MessageInfo.USERID);
String message = extra.getString(MessageInfo.MESSAGETEXT);
if (username != null && message != null) {
if (friend.userName.equals(username)) {
myarray.add(username + ":" + "\n" + message);
adapter.notifyDataSetChanged();
localstoragehandler.insert(username,
imService.getUsername(), message);
} else {
if (message.length() > 15) {
message = message.substring(0, 15);
}
Toast.makeText(Messaging.this,
username + " says '" + message + "'",
Toast.LENGTH_SHORT).show();
}
}
}
};
Logcat消息:
java.lang.RuntimeException:在com.android.app.Messaging$MessageReceiver@535d151c中接收广播Intent {act = Take_Message flg = 0x10(有额外内容)}时出错