Tôi đã tạo một bộ thu phát sóng trong hoạt động chính và dịch vụ nền đang gửi nội dung phát sóng. Các ứng dụng bị treo mỗi khi tôi cố gắng chạy nó và Log hiển thị thông báo lỗi sau:Lỗi khi nhận sự cố ý định phát sóng
10-04 13: 30: 43,218: LỖI/AndroidRuntime (695): java.lang.RuntimeException: Lỗi nhận Ý định phát sóng { action = com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE (có tính năng bổ sung)} trong [email protected]
thông điệp phát sóng được gửi từ Lớp CommunicationService theo phương thức sau:
private void announceLoginStatus(){
Intent intent = new Intent(LOGIN_STATUS_UPDATE);
intent.putExtra(SERVER_MESSAGE, mServerResponseMessage);
intent.putExtra(SESSION_STRING, mSessionString);
sendBroadcast(intent);
}
nơi
String LOGIN_STATUS_UPDATE = "com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE"
trong hoạt động chính reveiver phát sóng sau được xác định:
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();
}
}
và đăng ký tại phương pháp onResume:
IntentFilter loginStatusFilter;
loginStatusFilter = new IntentFilter(CommunicationService.LOGIN_STATUS_UPDATE);
loginStatusReceiver = new LoginStatusReceiver();
registerReceiver(loginStatusReceiver, loginStatusFilter);
Và file manifest tôi ncludes như sau:
<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>
Tôi thực sự đánh giá cao nếu có ai có thể giải thích lý do tại sao Nhật ký hiển thị thông báo ở trên và ứng dụng gặp sự cố.
Cảm ơn!
Có thể bạn có thể cho chúng tôi biết vấn đề là gì? – Buffalo