1
My project has several types of notifications. I created an ENUM where I store the type and id of the Notification.
final Intent intent = new Intent(getApplicationContext(),MainActivity.class);
intent.putExtra(TYPE, NotificationType.TYPE1.type);
intent.setFlags( Intent.FLAG_ACTIVITY_SINGLE_TOP);
final PendingIntent open = PendingIntent.getActivity(this, NotificationType.TYPE1.idNotification,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
Already in the MainActivity
, I invoke Cancel passing id as type:
String tipo = extras.getString(NotificationService.TYPE);
if(NotificationService.NotificationType.TYPE1.type.equals(tipo)){
NotificationManager.class.cast(this.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(NotificationService.NotificationType.TYPE1.idNotification);
}
On Smartphone, it removes correctly, but on Wear, it’s still open! If I click again on Wear (of some already closed on the smartphone) it displays a message from Didn’t Work!
Does anyone know if I can force it to close at Wear?
There is another way to cancel a Notification?