How to create a pending intent inside the BroadcastReceiver class?

I am trying to create a broadcast inside a broadcast receiver, but I do not think that I am entering the correct code for this. How will a waiting intern look for a broadcast receiver? I want to send a text message. And you need a delayed intention to send it.

+4
source share
1 answer

I am trying to create a broadcast inside a broadcast receiver, but I do not think that I am entering the correct code for it.

This is no different from any other PendingIntent except using the pass-in Context object, since BroadcastReceiver not Context :

 public void onReceive(Context ctxt, Intent incoming) { Intent i=new Intent(ctxt, OnAlarmReceiver.class); PendingIntent pi=PendingIntent.getBroadcast(ctxt, 0, i, 0)); // do stuff with PendingIntent here } 
+7
source

All Articles