Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to remove notification bar after time interval
    primarykey
    data
    text
    <p>This is my code that is working fine. It shows notification bar every 20 seconds if notification remove from notification bar but i want to remove notification from notification bar every 18 second and display again every 20 seconds what do i do? how do i remove notification form notification bar??</p> <pre><code> public class NotificationActivity extends Activity { AlarmManager am; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notification); am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); setRepeatingAlarm(); } public void setRepeatingAlarm() { Intent intent = new Intent(this, TimeAlarm.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (20 * 1000), pendingIntent); System.out.println("Calling Alaram..."); } } public class TimeAlarm extends BroadcastReceiver { NotificationManager nm; @Override public void onReceive(Context context, Intent intent) { nm = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); CharSequence from = "Lokesh"; CharSequence message = "Notification Test..."; PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0); Notification notif = new Notification(R.drawable.cherry_icon, "Notification Test...", System.currentTimeMillis()); notif.setLatestEventInfo(context, from, message, contentIntent); nm.notify(1, notif); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload