마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

GCM으로 메시지를 받았을때, 앱이 실행중일 경우, 아닐 경우 분기별로 액션을 다르게 하려고 합니다.

0 추천
 private void sendNotification(Bundle bundle) {

        mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

        Intent intent = new Intent(SplashActivity.class);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentTitle(bundle.getString("title"))
                        .setStyle(new NotificationCompat.BigTextStyle()
                                .bigText(bundle.getString("message")))
                        .setContentText(bundle.getString("message"));

        mBuilder.setContentIntent(contentIntent);

        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

앱이 실행하고 있지 않을 경우, SplashActivity, 실행했을 경우에는 MainActivity에 bundle를 넘기고 싶은데, 체크할 수 있는 방법이 뭐가 있을까요??

로켓군 (540 포인트) 님이 2015년 6월 4일 질문

2개의 답변

0 추천
top activity나 foreground 를 채크하는 걸로 구글링 해보세요
쎄미 (162,410 포인트) 님이 2015년 6월 4일 답변
0 추천
보통 RunningTaskInfo나 RunningAppProcessInfo 로 체크합니다.
컵받침 (5,500 포인트) 님이 2015년 6월 8일 답변
...