Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This may help you. First use this code for your alarm receiver class</p> <pre><code>public class AlarmReceiver extends BroadcastReceiver { NotificationManager nm; public void onReceive(Context context, Intent intent) { Toast.makeText(context, "Log Out !!", Toast.LENGTH_LONG).show(); // Vibrator vibrator=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); // vibrator.vibrate(1000); nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); CharSequence ch="Log Out Service"; CharSequence message="Log Out You have to login again!! "; Notification notif = new Notification(R.drawable.ic_launcher, "You Are Logged out...", System.currentTimeMillis()); // PendingIntent contentIntent = PendingIntent.getActivity(context, 0, // new Intent(), 0); Intent notifyintent=new Intent(context,AlarmManagerTestActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notifyintent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK); notif.flags |=Notification.FLAG_AUTO_CANCEL; notif.setLatestEventInfo(context, ch, message, pendingIntent); nm.notify(0, notif); } } </code></pre> <p>then put this code in your activity</p> <pre><code>Intent intent = new Intent(your activity,AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast( AlarmManagerTestActivity.this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent); </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.
    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