如何通过广播接收器刷新界面
来源:互联网 发布:ubuntu 挂载usb硬盘 编辑:程序博客网 时间:2024/06/06 14:12
第一步:注册广播public void registerBoradcastReceiver() {IntentFilter myIntentFilter = new IntentFilter();myIntentFilter.addAction(ComParams.ACTION_UPDATE_USER);registerReceiver(receiver, myIntentFilter);}
private BroadcastReceiver receiver = new BroadcastReceiver() {//内部类@Overridepublic void onReceive(Context context, Intent intent) {String action = intent.getAction();if (action.equals(ComParams.ACTION_UPDATE_USER)) {//接收广播消息刷新界面}}};
第二步:发送广播消息
Intent intent = new Intent(ComParams.ACTION_UPDATE_USER);//发送刷新广播context.sendBroadcast(intent);
第三步:在Activity生命周期结束的时候取消注册
protected void onDestroy() {super.onDestroy();try {super.onDestroy();ULog.i(TAG, "onDestroy ===> unregisterReceiver");if (receiver != null) {unregisterReceiver(receiver);}} catch (Exception e) {e.printStackTrace();}}
1
0 0
- 如何通过广播接收器刷新界面
- Fragment通过广播刷新界面
- Fragment通过广播刷新界面
- 广播接收器
- 广播接收器
- Android中的广播接收器之电话快捷启动界面
- 如何通过<a></a>中的href刷新当前界面
- BroadCastReceiver android 广播接收器
- 使用广播接收器
- BroadcastReceiver 广播接收器
- BroadcastReceiver(广播接收器)
- android 广播与 接收器
- BroadcastReceiver(广播接收器 )
- BroadcastReceive广播接收器:
- @EReceiver加强广播接收器
- Android 广播接收器BroadcastReceiver
- 广播接收器动态注册
- 广播接收器的使用
- EditText 文字改变的情况的监听器
- js 常用方法
- const 修饰成员函数
- Timer 定时器类 java
- 经典SQL语句大全
- 如何通过广播接收器刷新界面
- 第6周作业-图像缩放显示
- ios短信分享功能
- MFC窗口和控件大小等比例变化
- malloc()与 alloc()区别 (转)
- 测试JSON是否可用
- yii yii CActiveDataProvider condition like
- 如果很喜欢很喜欢一个人
- ruby学习笔记(9)-别名(alias)与方法取消(undef,remove_method)