在开发SMS等应用时,有时调用相关的API会要求提供一个类型为PendingIntent的参数,那么这个PendingIntent是啥东西呢
A PendingIntent specifies an action to take in the future. It lets you pass a future
Intent to another application and allow that application to execute that Intent as
if it had the same permissions as your application, whether or not your application is still around when the Intent is eventually invoked. A PendingIntent provides a
means for applications to work, even after their process exits. It’s important to note that even after the application that created the PendingIntent has been killed, that Intent can still run.
上文来自android in action一书,总结来说就是:
1、PendingIntent可以把权限带过去,使目标应用获得当前应用的permissions
2、PendingIntent是在将来的某个时间点执行的,即使创建PendingIntent的应用在那个时候已经结束了生命周期,这个Intent依然会被执行
创建PendingIntent的代码类似于
PendingIntent.getActivity(context,requestCode,intent,flags);
context是当前的上下文;requestCode是请求代码,一般是0;intent就是将来要执行的intent;flags不知道是啥,看很多代码一般也是设置成0
分享到:
相关推荐
这样我们就可以画出如下示意图:PendingIntent 只能通过下列的静态方法获取//获取Broadcast关联的PendingIntent PendingI
博客《详解PendingIntent》所涉及的源码,这是博客中所说的有问题的PendingIntent对应原源代码
Android中pendingIntent的深入理解
博客《详解PendingIntent》有问题的源码第二部分
Notification的用法和PendingIntent的使用
自制发送短信程序--SmsManager与PendingIntent类的使用
NULL 博文链接:https://sunzone.iteye.com/blog/1998091
PendingIntent 分别实现了Notification和sms短信发送的两个示例
android的服务以及通知的小例子 个人存档 代码笔记见http://blog.sina.com.cn/s/blog_70356c200100y9pf.html
本文实例讲述了Android编程实现PendingIntent控制多个闹钟的方法。分享给大家供大家参考,具体如下: 要用 android.app.PendingIntent.getBroadcast(Context context, int requestCode, Intent intent)来实现控制多...
简单的总结了Intent和PendtingIntent的区别,经常与alermanger 和notificationmanager一起使用。
PendingIntent mPI = PendingIntent.getBroadcast(EX05_03.this, 0, new Intent(), 0); smsManager.sendTextMessage(strDestAddress, null, strMessage, mPI, null); } catch(Exception e) { e....
NULL 博文链接:https://technicalsearch.iteye.com/blog/2007636
实现可定时响起的闹钟----PendingIntent 与 AlarmManager 的运用
根据本讲学习内容,学会运用AlarmManager和PendingIntent实现定时提醒功能。 (1) 提交的作业包中含有应用程序运行效果截图。
Android中PendingIntent的简要介绍.pdf 学习资料 复习资料 教学资源
android 自制发送短信程序 SmsManager与PendingIntent对象
Android中pendingIntent的深入分析 pendingIntent字面意义:等待的,未决定的Intent。 要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, int, Intent, int),getBroadcast(Context, int, ...