Skip to content

Commit

Permalink
do synchronized action listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
pavly-gerges committed May 21, 2021
1 parent b26442b commit 1a44f3c
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ public OnActionsListener() {
@Override
protected void onHandleIntent(@Nullable Intent notificationIntent) {
assert notificationIntent != null;
if(notificationIntent.getAction().equals(BackgroundTask.ACTION_TEST_JME)){
//start another explicit intent implicitly from an IntentService which is directed using a PendingIntent from a notification action
Intent intent = new Intent(getApplication(), HolderActivity.class);
//start an activity from outside the context flag
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.deleteNotificationChannel(NotificationUtils.CHANNEL_ID);
notificationManager.cancelAll();
Toast.makeText(getApplicationContext(), "Powered By Jme", LENGTH_LONG).show();
}else if(notificationIntent.getAction().equals(BackgroundTask.ACTION_DISMISS)){
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.deleteNotificationChannel(NotificationUtils.CHANNEL_ID);
notificationManager.cancelAll();

synchronized(this){
if ( notificationIntent.getAction().equals(BackgroundTask.ACTION_TEST_JME) ){
//start another explicit intent implicitly from an IntentService which is directed using a PendingIntent from a notification action
Intent intent = new Intent(getApplication(), HolderActivity.class);
//start an activity from outside the context flag
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.deleteNotificationChannel(NotificationUtils.CHANNEL_ID);
notificationManager.cancelAll();
Toast.makeText(getApplicationContext(), "Powered By Jme", LENGTH_LONG).show();
} else if ( notificationIntent.getAction().equals(BackgroundTask.ACTION_DISMISS) ){
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.deleteNotificationChannel(NotificationUtils.CHANNEL_ID);
notificationManager.cancelAll();
}
}
}
}

0 comments on commit 1a44f3c

Please sign in to comment.