, 아래 코드 :안드로이드 SMS 리스너 나는 SMS 리스너 함께 일하고 잘못된 응용 프로그램 컨텍스트
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
EventEntry entry = ((MyApplication)context.getApplicationContext()).getCurrent();
System.out.println("Received message: " + smsMessage[0].getMessageBody() + " - SILENCE IS " + ((entry != null) ? "ON" : "OFF"));
}
}
그리고 다음 수정을위한 브로드 캐스트 리시버에 내 코드의 다른 부분에서 AndroidManifest를
<application
android:name="MyApplication" ...
(에 AlarmManager), 가지고있어
public void onReceive(Context context, Intent intent) {
((MyApplication).context.getApplicationContext()).setCurrent("TESTING");
}
그러나 응용 프로그램을 실행하고 예제 텍스트를 보낼 때 나는 날개 디버그 메시지 :
09-15 15:07:30.974: I/System.out(21625): DEBUG!!!!!! Setting current event to TESTING
09-15 15:07:54.399: I/System.out(21605): DEBUG!!!!!! Getting current event: null
내 응용 프로그램 컨텍스트가 동기화되지 않는 이유는 무엇입니까?
감사합니다.