알람 관리자와 브로드 캐스트 수신기를 사용하는 알람 시계 앱이 있습니다. 앱은 하나의 활동이며 4 개의 조각입니다. 알람이 울리면 onReceive 메소드는 인 텐트를 주 활동으로 보내고 주 활동은 onIewIntent 메소드에서이 인 텐트를 수신 한 다음 올바른 프래그먼트로 이동합니다. 앱이 종료 된 후 알람이 울리는 경우를 제외하고 모든 것이 잘 작동합니다.onNewIntent가 다시 시작될 때 호출되지 않음
일단 앱을 파괴하면 알람이 계속 울리며 브로드 캐스트 리시버의 의도가 실행되지만 onNewIntent 메소드는 의도를 파악하여 앱을 올바른 조각으로 이동시킵니다. 여기
는 알람이 때 응용 프로그램을 호출 할 때 호출 점점되지 내 주요 활동 내 onNewIntent 방법의 주요 활동 여기Intent alarmIntent = new Intent(context, ClockActivity.class);
alarmIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
alarmIntent.putExtra("Alarm Name", receivedAlarm.getmName());
context.startActivity(alarmIntent);
로 이동 방송 수신기 클래스에 텐트입니다 닫혀있다.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
PhraseFragment phraseFragment = new PhraseFragment();
String activeName = intent.getStringExtra("Alarm Name");
Bundle args = new Bundle();
args.putString("activeName", activeName);
phraseFragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.container, phraseFragment)
.addToBackStack("phrase")
.commit();
}
참조 : http://stackoverflow.com/questions/8800006/onnewintent-is-not-called-in-android-tabs – grebulon