Guest User

Untitled

a guest
Jun 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public void onNotificationPosted(StatusBarNotification sbn) {
  2. if (sbn.getId() != 12321) {
  3. this.cancelAllNotifications();
  4. }
  5. NotificationManager mNotificationManager =
  6. (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  7.  
  8. if(!PhoneStateManager.getInstance().isDesconectado())
  9. return;
  10.  
  11.  
  12.  
  13. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  14.  
  15. am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
  16. cancelAllNotifications();
  17.  
  18. Intent i = new Intent();
  19. PendingIntent mBlankIntent=PendingIntent.getActivity(getBaseContext(), 0, i,PendingIntent.FLAG_UPDATE_CURRENT);
  20. if (sbn.getId() != 12321) {
  21. mNotificationManager.notify(12321, new Notification.Builder(this)
  22. .setContentTitle("").setContentText("")
  23. .setSmallIcon(R.drawable.transparent)
  24. .setPriority(Notification.PRIORITY_HIGH)
  25. .setFullScreenIntent(mBlankIntent, false)
  26. .setAutoCancel(true)
  27. .build());
  28.  
  29. mNotificationManager.cancel(12321);
  30. mNotificationManager.cancelAll();
  31.  
  32. }
  33.  
  34.  
  35. Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  36. sendBroadcast(closeIntent);
  37. }
Add Comment
Please, Sign In to add comment