So öffnen Sie eine andere Aktivität als Launcher -Aktivität in Android, wenn wir auf Benachrichtigung klickenJava

Java-Forum
Anonymous
 So öffnen Sie eine andere Aktivität als Launcher -Aktivität in Android, wenn wir auf Benachrichtigung klicken

Post by Anonymous »

Ich verwende FCM -Benachrichtigungen in meiner App und möchte eine Aktivität namens ManagesalesMainActivity öffnen, die keine Launcher -Aktivität darstellt und mithilfe der ausstehenden Absichten die String übergeben möchte. Ich kann den String jedoch nicht in Splashscreen einbringen.

Code: Select all

 Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {100, 300, 300, 300};
v.vibrate(pattern, -1);

NotificationCompat.Builder builder = new
NotificationCompat.Builder(this,"CHANNEL_ID");

Intent resultIntent = new Intent(this, ManageSalesMainActivity.class);
resultIntent.putExtra("order_status",message_status);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 1,
resultIntent, PendingIntent.FLAG_IMMUTABLE);

builder.setContentTitle(Objects.requireNonNull(remoteMessage.getNotification())
.getTitle());
builder.setContentText(remoteMessage.getNotification().getBody());
builder.setContentIntent(pendingIntent);
builder.setStyle(new
NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification()
.getBody()));

builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.go_local_logo_without_bg);
builder.setVibrate(pattern);
builder.setPriority(Notification.PRIORITY_MAX);

mNotificationManager=NotificationManager)getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// String ChannelID = "Your_Channel_id";
String ChannelId = "Channel_id";

Code: Select all

        NotificationChannel channel = new NotificationChannel(
channelId,
"Channel human readable title",
NotificationManager.IMPORTANCE_HIGH);
channel.enableLights(true);
channel.enableVibration(true);
channel.setVibrationPattern(pattern);
channel.canBypassDnd();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
channel.canBubble();
}

mNotificationManager.createNotificationChannel(channel);
builder.setChannelId(channelId);
}

mNotificationManager.notify(1000, builder.build());

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post