(十一)RemoteViews的使用解析
来源:互联网 发布:波士顿矩阵图怎么制作 编辑:程序博客网 时间:2024/06/07 00:02
使用场景:桌面小部件和通知栏。
PendingIntent:待定的意图。
支持三种待定意图:getActivity(Context context,int requsetCode,Intent intent,int Flag)相当于Context.startActivity(intent)
getService(Context context,int requsetCode,Intent intent,int Flag)相当于Context.startService(intent)
getBroadcast(Context context,int requsetCode,Intent intent,int Flag)相当于Context.startBroadcast(intent)
注:requsetCode多数情况下设置为0即可,他会影响到flags的效果。
PendingIntent的匹配规则:requestCode相同 ,内部Intent相同:ComponentName和intent-filter都相同,Extras不参与匹配。
flags分类:
FLAG_ONE_SHOT : PendingIntent只能被使用一次,就会被自动cancel。后续相同的PendingIntent的send方法会失效。
FLAG_NO_CREATE : 当前描述的PendingIntent不会主动创建,如果之前不存在,getXXX方法返回null。不怎么使用
FLAG_CANCEL_CURRENT: 当前描述的PendIntent若已经存在,那么他们都会被cancel,然后系统创建新的,被cancel的将不会被打开
FLAG_UPDATE_CURRENT: 当前描述的PendIntent若已经存在,会被更新。数据会被替换成新的。
RemoteView的内部机制
RemoteView只支持特定的View。
布局:Framelayout、LinearLayout、RelativeLayout、GridLayout。
View:Button 、ListView、GridView、ImageButton、ImageView、TextView、ViewStub、ProgressBar等。
首先RemoteView会通过Binder传递到SystemServer进程,系统会根据RemoteViews的包名等信息去得到相应的资源。然后通过LayoutInflate去加载RemoteViews中的布局文件,在SystemServer中加载后的布局文件只是一个普通的View,相对于我们的进程它是RemoteViews,接着系统会对他进行一系列的更新操作,是通过set提交的。但set方法对界面更新并不立即执行,在RemoteView的内部会记录所有的更新操作,等RemoteViews被加载后才会执行,这样RemoteViews就可以在SystemServer中显示了。
每个set操作会封装到RemoteViews内部的Action中,在远程进程中会通过RemoteViews的Action的apply方法和reApply方法。
apply和reAppLY方法异同:apply加载布局更新界面,reApply方法只更新界面。内部通过反射方式来调用所需的方法。
构造函数:
阅读全文
0 0
- (十一)RemoteViews的使用解析
- RemoteViews的解析
- RemoteViews的使用
- RemoteViews的使用
- RemoteViews使用
- 022.RemoteViews的介绍和使用
- RemoteViews完全解析
- 使用RemoteViews自定义Notification
- RemoteViews使用setImageResource出错
- RemoteViews之RemoteViews的内部机制
- RemoteViews在桌面小部件和通知栏的使用
- Android RemoteViews的基本使用(上)之通知栏
- Android RemoteViews的基本使用(下)之窗口小部件
- Android的RemoteViews
- RemoteViews的应用
- RemoteViews的用处
- RemoteViews的用途
- RemoteViews的内部机制
- 为什么推荐InnoDB引擎使用自增主键?
- git常用指令
- win10 通过composer安装yii2 方法
- 在linux下安装chrome 浏览器
- hdu 6035 Colorful Tree
- (十一)RemoteViews的使用解析
- 找不到元素'beans'的声明
- linux查看网络状态命令
- linux 多线程消息广播
- Jsp自定义标签
- python:unindent does not match any outer indentation level
- jquery知识结构
- CSS清除浮动的几种方式
- CSDN第一天