0

서비스에서 GCM 메시지를 수신하고 있습니다. 나는 메시지를 여분으로 넣고 시작하고자하는 클래스에 전달한다. 거기에 대화 상자 안에 메시지를 표시한다.서비스에서 활동을 시작하고 내용을 업데이트하는 방법이 있습니까?

하지만 다음에 내가 의도 한 내용을 업데이트해야한다는 메시지가 나타나면 예외가 발생하고 응용 프로그램이 다운되고 이클립스가 충돌을 해결하기 위해 "FLAG_ACTIVITY_NEW_TASK"를 사용하게됩니다. 하지만이 방법으로 내 "PendingIntent.FLAG_UPDATE_CURRENT"는 무시됩니다.

어떻게 이전에 열린 의도를 업데이트 할 수 있습니까? 세 번째 활동을 생성하고 데이터를 다시 전달하면 요새가 나쁘게 보입니다.

서비스 클래스 :

 ... 

private void sendNotification(String msg, Bundle extras) 
     { 
     mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); 

     Intent intent = new Intent(this, DriverDetails.class); 
     intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
     // If this is a notification type message include the data from the message 
     // with the intent 
     if (extras != null) 
     { 
      intent.putExtras(extras); 
      intent.putExtra("message", msg); 
      intent.setAction("com.myGcm.NOTIFICATION"); 
      startActivity(intent); 
     } 
     PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 
      PendingIntent.FLAG_UPDATE_CURRENT); 

     NotificationCompat.Builder mBuilder = 
      new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_stat_cloud) 
      .setContentTitle("GCM Notification") 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) 
      .setContentText(msg) 
      .setTicker(msg) 
      .setAutoCancel(true) 
      .setSound(Settings.System.DEFAULT_NOTIFICATION_URI); 

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

... 
+0

, 나는 느릅 나무가 당신을 안내해야 두 개의 링크를 첨부? –

+0

@Aashish - 들어오는 모든 메시지를 최종 사용자에게 목록 형식으로 표시해야합니다. –

+0

서비스에서 알림을 시작하십시오. 클릭하면 활동을 시작하도록 알림을 설정하십시오. –

답변

관련 문제