0
사용자가 푸시 알림을 눌러 앱을 열 때 다른 활동을 열려고합니다.데이터가있는 Android GCM 앱 열기
이 활동은 기본 활동 상단에 있어야합니다. 사용자가 알림을 누르면 그래서 때 스택은 다음과 같아야합니다
활동 A -> 활동 B. 내가 생각하는 지금
이 상황들이있다 :이 앱은 이미 주 (실행
- 활동이 이미 표시됨)
- 앱이 실행되고 있지 않습니다. (주요 활동은 제공되지 않습니다)
내 질문 : 어떻게 스택에 주요 활동과 함께 새로운 활동을 보여주는 응용 프로그램을 열어야합니까?
코드는 앱이 이미 실행 중일 때만 작동하므로 (주 활동이 이미 스택에 있음)
Intent notificationIntent = new Intent(this, ExtraActivity.class);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.setAction(Intent.ACTION_MAIN);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
String appName = getResources().getString(R.string.app_name);
int icon = R.drawable.ic_launcher;
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(icon)
.setContentTitle(appName)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setContentText(message);
mBuilder.setContentIntent(pendingIntent);
mNotificationManager.notify(uniqueId, mBuilder.build());