1.RemoteViewshtml
官方介绍:A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy. 翻译:一个描述视图的类,该视图能够在另外一个进程中显示。构造时须要制定一个layout资源文件,该类提供了一些基本的操做方法来修改所描述的视图内容。java
a.做用:为跨进程生成控件和修改控件属性提供一系列方法python
注意:RemoteViews只是实现了Parcelable 接口,严格讲它并非一个View,只是一个操做类 android
![]()
b.使用性能优化
public RemoteViews(String packageName, int layoutId) {
this(getApplicationInfo(packageName, UserHandle.myUserId()), layoutId);
}
复制代码
setTextViewText(int viewId, CharSequence text)
:设置TextView显示的文字setImageViewResource(int viewId, int srcId)
:设置ImageView显示的图片setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
:设置View的监听事件c.应用场景:具体步骤见5.1RemoteViews的应用ide
NotificationManager#notify()
AppWidgetProvider
d.优缺点:函数
FrameLayout、LinearLayout、RelativeLayout、GridLayout、AnalogClock、Button、Chronometer、ImageButton、ImageView、ProgressBar、TextView、ViewFlipper、ListView、GridView、StackView、AdapterViewFlipper、ViewStub工具
推荐阅读:源码分析见Android UI之跨进程组件RemoteViews源码分析
2.PendingIntent布局
a.做用:是待定Intent,让意图在合适的时间再执行,而不是当即执行
b.经常使用构造:
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags)
:打开页面public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags)
:发送广播public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags)
:开启服务c.参数描述:
context
:上下文requestCode
:PendingIntent发送方的请求码,通常设为0intent
:意图,当PendingIntent发生时,效果与startActivity()、sendBroadcaset()、startService()同样flags
:常见的类型以下
FLAG_ONE_SHOT
:描述的PendingIntent只能使用一次,以后会被cancelFLAG_NO_CREATE
:若描述的PendingIntent不存在,直接返回null而不是建立FLAG_CANCEL_CURRENT
:若描述的PendingIntent已存在,则都会被cancel,以后再建立一个新的FLAG_UPDATE_CURRENT
:若描述的PendingIntent已存在,就都会被updated.匹配规则:知足内部Intent相同且requestCode也相同,则两个PendingIntent是相同的
3.JNI & NDK & ADB & AAPT
a.JNI
b.NDK
c.ADB
d.AAPT
4.一点小感悟
近日最大的感觉就是——年味不要太浓!年前年后那两周一直都处于“人不齐”状态、初八开工以来收红包收到手软、处处品尝同事从家乡带来的年货、出去聚餐也有了“正当”理由、元宵节的汤圆好好吃...进来感觉下开工日的盛况~腾讯开工刷红包堪比“春运",沙发板凳姜茶暖宝宝全上场
这周对我年前写的代码进行了review,来了十几个大佬,虽然提早作了准备可是仍是紧张,短短一个半小时真的学到不少,除了技术上的收获,也给我从此再准备相似会议提供一些启发,例如,在讲代码前要先交代好背景,不是全部人都清楚具体需求,减小解释成本;演示大纲颇有必要,但也要随时准备被提问各类问题、打乱节奏;最好走个完整流程来展现代码逻辑,只看代码的改动部分很难被理解...总之第一次作review仍是挺不错的体验,很是感谢小哥哥们的耐心和建议~