안녕하세요 GCM 푸시 Client 구현중이 있습니다.
푸시 알림이 처음와서 푸시를 클릭하면 해당 Activity로 이동을 잘합니다.
그리고 새로운 이벤트가 발생하여 다른 푸시가 발생되었을때
기존 푸시에 왔던 Activity를 죽이고 새로운 데이터가 세팅된 Activity를 띄워야하는데
클릭했을때 새로운 Activity가 안뜨네요... (기존 Activity랑 새롭게 떠야하는 Activity는 동일 Class로 된 Activity 입니다 )
기존 Activity가 떠 있는 상태에서 알림 계속 뜨는데 클릭이후 해당 새로운 Activity로 이동을 안하고 기존 Activity가 그대로
화면에 존재합니다. 이문제는 어떻게 하면 좋을까요....PendingIntent 플래그를 바꾸어도 새로운 화면으로 안나오네요
PendingIntent.FLAG_ONE_SHOT
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_NO_CREATE
PendingIntent.FLAG_UPDATE_CURRENT
플래그를 바꿔가면서 해줘도 안되네요...
소스코드는 아래와 같습니다.
public class GcmIntentService extends IntentService{
public static final int NOTIFICATION_ID = 1;
public GcmIntentService(){
super("GcmIntentService");
}
@Override
protected void onHandleIntent(Intent intent){
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()){
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)){
sendNotification("Send error: " + extras.toString(),"");
}else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)){
sendNotification("Deleted messages on server: " + extras.toString(),"");
// If it's a regular GCM message, do some work.
}else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)){
String msg = intent.getStringExtra("msg");
String erp_id = intent.getStringExtra("erp_id");
String encoding1 = null ;
String encoding2 = null ;
try {
encoding1 = URLDecoder.decode(msg,"UTF-8");
encoding2 = URLDecoder.decode(erp_id,"UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Post notification of received message.
// sendNotification("Received: " + extras.toString());
sendNotification(encoding1,encoding2);
Log.d("GcmIntentService", "호출1");
}
}
// Release the wake lock provided by the WakefulBroadcastReceiver.
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
// Put the message into a notification and post it.
// This is just one simple example of what you might choose to do with
// a GCM message.
private void sendNotification(String msg,String erp_id){
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(getApplicationContext(), ActivityNotification.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("msg", msg);
intent.putExtra("erp_id", erp_id);
// PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("알림")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg)
.setAutoCancel(true)
.setVibrate(new long[] { 0, 500 });
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
}
고수님들 도와주십쇼...
감사합니다.