0

내 서비스의 OnstartCommand()에서 전경 알림을 설정했습니다. 내 MainActivity에서 알림의 텍스트를 어떻게 업데이트 할 수 있습니까?업데이트 활동에서의 착신 알림

Intent notificationIntent = new Intent(this, MainActivity.class); 
     notificationIntent.setAction("new"); 
     notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 
     notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, 
       notificationIntent, 0); 
     Bitmap icon = BitmapFactory.decodeResource(getResources(), 
       R.drawable.ic_launcher); 
     // builder = new NotificationCompat.Builder(this); 

     notification = new NotificationCompat.Builder(this) 
       .setContentTitle("Test") 
       .setTicker("Test") 
       .setContentText("Update This") 
       .setSmallIcon(R.drawable.ic_launcher) 
       .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)) 
       .setContentIntent(pendingIntent) 
       .setOngoing(true).build(); 
     startForeground(101, notification); 

답변

1

동일한 notificationId를 사용하여 MainActivity에 새 알림을 보냅니다.