0
通知をクリックしてアクティビティを開始しようとしていますが、これは既にアプリ内にあるときにのみ機能します。通知をクリックするとアクティビティを開始します
ここで私はそれに関係していると思うのコードです:
private void sendNotification(String body) {
Intent intent = new Intent(ImpFirebaseMessagingService.this, codeActivity.class);
intent.putExtra("body", body);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Implementation TFA")
.setContentText(body)
.setAutoCancel(true)
.setSound(notificationSound)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
は、このコードはサービスに書かれていますか? – shadygoneinsane
@shadygoneinsane私はチュートリアルに従いました。ファイル名はMyFirebaseMessagingService –