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

화면 꺼짐 상태에서 gcm push받기..

0 추천

구글링 결과, delayWhileIdle을 false로 해주면 screen-off상태에서도 알림이 온다는데 전 작동을 안하는군요;

검색해도 답이안보여서 재차 질문드립니다.

 

서버 소스입니다.

Message message = new Message.Builder().
collapseKey(String.valueOf(Math.random() % 100 + 1)).
delayWhileIdle(false).
addData("msg", this.msg).
addData("title", "Android").
build();
 
 
intentservice 쪽 소스입니다.
 
 
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
Intent intent = new Intent(getApplicationContext(), WakeUpActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("msg", msg);
 
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
 
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("TEST")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg).setAutoCancel(true)
.setDefaults(2)
.setVibrate(new long[] { 0, 500 });
 
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
 
 
receiver 쪽 소스입니다.
 
public void onReceive(Context context, Intent intent) {
 
Bundle bundle = intent.getExtras();
 
ComponentName comp = new ComponentName(context.getPackageName(),
GCMIntentService.class.getName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startWakefulService(context, intent.setComponent(comp));
setResultCode(Activity.RESULT_OK);
 
startWakefulService(context, intent);
}

 

뭐가 잘못된 걸 까요?

김울프 (860 포인트) 님이 2014년 6월 16일 질문

1개의 답변

0 추천
 
채택된 답변
자답입니다...

인텐트서비스 쪽에서 명시적으로 액티비티 호출하면 되는거였군요..ㅠㅠ
김울프 (860 포인트) 님이 2014년 6월 16일 답변
...