Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(), 0); </code></pre> <p>You are passing a blank Intent here . Change this to the intent of Activity you want to all, for example :</p> <pre><code>PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(context,MyActivity.class), 0); </code></pre> <p>Try the following Activity:</p> <pre><code>public class TestAlarmActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // get a Calendar object with current time Calendar cal = Calendar.getInstance(); // add 5 minutes to the calendar object cal.add(Calendar.MINUTE, 5); Intent intent = new Intent(this, AlarmReceiver.class); intent.putExtra("alarm_message", "O'Doyle Rules!"); // In reality, you would want to have a static variable for the request code instead of 192837 PendingIntent sender = PendingIntent.getBroadcast(this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Get the AlarmManager service AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000, sender); Toast.makeText(this, "tii;;; inside", Toast.LENGTH_LONG).show(); } </code></pre> <p>and the following Broadcastreceiver:</p> <pre><code>public class AlarmReceiver extends BroadcastReceiver { private NotificationManager nm; @Override public void onReceive(Context context, Intent arg1) { // TODO Auto-generated method stub Toast.makeText(context, "inside", Toast.LENGTH_LONG).show(); nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); CharSequence from = "Raja"; CharSequence message = "My First App..."; PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(), 0); Notification notif = new Notification(R.drawable.ic_launcher,"Crazy About Android...", System.currentTimeMillis()); notif.setLatestEventInfo(context, from, message, contentIntent); nm.notify(1, notif); } </code></pre> <p>I think your alarm is not getting executed because <strong>it has already passed</strong> as you are passing day of month as 25</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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