102_widget的点击事件
2014-08-01 16:03
176 查看
//点击后,发一个自定义的延迟意图。在应用程序中,通过广播接收者,接收该延迟意图,然后。。。。。。。。
一、在更新widge界面的服务中
task = new TimerTask() {
@Override
public void run() {
AppWidgetManager awm = AppWidgetManager.getInstance(getApplicationContext());
ComponentName component = new ComponentName(getApplicationContext(), MyWidget.class);
RemoteViews views = new RemoteViews(getPackageName(),R.layout.process_widget);
views.setTextViewText(R.id.process_count,"正在运行:");
views.setTextViewText(R.id.process_memory,"可用内存:");
Intent intent = new Intent();
intent.setAction("com.itheima.killall"); //自定义的意图
//设置一个自定义的广播事件 动作 com.itheima.killall
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
views.setOnClickPendingIntent(R.id.btn_clear, pendingIntent);
awm.updateAppWidget(component, views);
}
};
二、自定义一个广播接收者,过滤自定义的意图("com.itheima.killall")
一、在更新widge界面的服务中
task = new TimerTask() {
@Override
public void run() {
AppWidgetManager awm = AppWidgetManager.getInstance(getApplicationContext());
ComponentName component = new ComponentName(getApplicationContext(), MyWidget.class);
RemoteViews views = new RemoteViews(getPackageName(),R.layout.process_widget);
views.setTextViewText(R.id.process_count,"正在运行:");
views.setTextViewText(R.id.process_memory,"可用内存:");
Intent intent = new Intent();
intent.setAction("com.itheima.killall"); //自定义的意图
//设置一个自定义的广播事件 动作 com.itheima.killall
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
views.setOnClickPendingIntent(R.id.btn_clear, pendingIntent);
awm.updateAppWidget(component, views);
}
};
二、自定义一个广播接收者,过滤自定义的意图("com.itheima.killall")
相关文章推荐
- widget 点击事件突然失效
- 7.5 widget内的内容更新和点击事件
- Widget的点击事件
- RemoteViews用法二:可以接收点击事件并改变外观的widget
- ANDROID_MARS学习笔记_S02_006_APPWIDGET2_PendingIntent及RemoteViews实现widget绑定点击事件
- Android Widget点击事件
- android appwidget 点击事件详解 多个控件多个按钮不同响应
- android 转载 widget点击事件
- Widget的点击事件
- Qt QTableWidget 点击事件 重复问题的解决
- 界面更新android 转载 widget点击事件界面更新
- QTableWidget 空单元格,忽略点击事件
- 在Activity中响应ListView内部按钮的点击事件的两种方法!!!
- 多个点击按钮事件 老大教的
- Android6.0源码解读之Activity点击事件分发机制
- 图片放大缩小的区域点击事件代码例子
- 自定义导航栏返回按钮点击事件
- 阻止浏览器默认的点击事件
- windows phone listbox的点击事件
- 单元格点击事件