how to create a pending intent inside of a BroadcastReceiver class?
I'm trying to create I broadcast intern inside of a broadcast receiver but I don't think I'm entering the right code for it. How should the pending intern look for the broadcast receiv开发者_JS百科er? I want to send a text message. And need the pending intent to send it.
I'm trying to create I broadcast intern inside of a broadcast receiver but I don't think I'm entering the right code for it.
It is no different than any other PendingIntent, other than you have to use the passed-in Context object, since BroadcastReceiver is not a 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
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论