开发者

how to create a pending intent inside of a BroadcastReceiver class?

开发者 https://www.devze.com 2023-03-15 16:47 出处:网络
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百科

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号