Ich habe ein Problem, brauche deine Hilfe, ich habe meine App im Vordergrund und wenn ich die Benachrichtigung vom Server senden, dann kommen die Benachrichtigung mit dem Benachrichtigungssymbol.Wie kann ich das Benachrichtigungssymbol schließen, wenn sich meine App im Vordergrund befindet?
aber was ich brauche, wenn meine App im Vordergrund Benutzer ist, sieht die Benachrichtigung dann Benachrichtigung Symbol sollte nicht für den Benutzer angezeigt werden.
Wenn meine App im Hintergrund ist/oder wenn die App nicht gestartet wird, sollte die Benachrichtigung mit dem Benachrichtigungssymbol erscheinen und das Symbol für die Benutzerbenachrichtigung und das Benachrichtigungssymbol werden ignoriert.
Ich hatte versucht:
if(getIntent()!=null){
Log.e("getIntent","getIntent");
broadcastReciver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(NOTIFY_ACTIVITY_ACTION))
{
if(intent.getExtras().getBoolean("reload")){
int notificationId = intent.getIntExtra("notificationId", 0);
Log.e("notificationId","notificationId---"+notificationId);
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(notificationId);
setFragmentView(0);
//finish();
}
}
}
};
}
In onMessageReceived:
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("notificationId",NOTIFICATION_ID);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.splash_logo)
.setContentTitle("Logizo")
.setContentText("New Order Arrived")
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID/* ID of notification */, notificationBuilder.build());
was genau möchten Sie tun? Sie möchten nicht, dass die Benachrichtigung angezeigt wird, wenn sich Ihre App im Vordergrund befindet? – Prashant
@ Prashant ja es ist jetzt gelöst. –