Handler클래스에는 handleMessage(Message msg)매소드가 있죠.
여기서 Activity를 호출하면 문제가 되는 가요?
액티비티에 Handler클래스를 상속받은 IncomingHandler를 만들고
@Override
public void handleMessage(Message msg) {
#1 or #2 or #3 or #4
}
아래와 같은 #1 ~#4 방법으로 OKActivity액티비티를 뛰우면 70%정도는
화면이 뜨고 나머지는 그냥 지나치고 handleMessage()를 종료합니다.
handleMessage마지막에 Log를 찍어보면 그렇게 되죠.
OKActivity액티비티 내부 onCreate()에 Log.v()를 두고
뜨지 않는 30%경우 로그를 보면 찍히지 않습니다. 안드로이드 프레임워크상에서
OKActivity 를 실행없이 지나치는 것으로 보입니다.
handleMessage()가 처리할 이벤트가 발생할 때 100%로 OKActivity가 켜져야 합니다.
무엇이 더 필요할 까요?
#1
Bundle bundle = new Bundle();
bundle.putInt("aNumber", mNumberOfResult);
Intent popupIntent = new Intent(getApplicationContext(), OKActivity.class);
popupIntent.putExtras(bundle);
PendingIntent pendingIntent= PendingIntent.getActivity(getApplicationContext(), 0, popupIntent, PendingIntent.FLAG_ONE_SHOT);
try {
pendingIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
#2
Bundle bundle = new Bundle();
bundle.putInt("aNumber", mNumberOfResult);
Intent popupIntent = new Intent(getApplicationContext(), OKActivity.class);
popupIntent.putExtras(bundle);
PendingIntent pendingIntent= PendingIntent.getActivity(getApplicationContext(), 0, popupIntent, PendingIntent.FLAG_ONE_SHOT);
startActivity(popupIntent);
#3
Intent popupIntent = new Intent(getApplicationContext(), OKActivity.class);
startActivity(popupIntent);
#4
runOnUiThread(new Runnable(){
public void run() {
Log.d(TAG,"runOnUiThread()");
Bundle bundle = new Bundle();
bundle.putInt("aNumber", mNumberOfResult);
Intent popupIntent = new Intent(getApplicationContext(), OKActivity.class);
popupIntent.putExtras(bundle);
startActivity(popupIntent);
}
});
----------------------------
Intent popupIntent = new Intent(getApplicationContext(), OKActivity.class);
Intent popupIntent = new Intent(this, OKActivity.class);
Intent popupIntent = new Intent(MainActivity, OKActivity.class);
로 바꾸어 해보아도 역시 결과는 같았습니다.