解决方案 »
- 求助,android调用so库文件报错
- android Failed to initialize Monitor Thread: Unable to establish loopback conn
- 【求助】开发了一个软件,替换出问题了
- 如何判断取到的联系人的姓名是否为空android
- 【初学案桌】问个debug的问题
- EPSON TX400 连供
- 联网时获取响应码时卡住该怎么办
- 关于android socket通信接收服务器数据问题
- Android 微信分享的问题
- android调用wcf,如何进行数据加密???
- android 中如何实现小球的发射,之后碰撞到物体再反弹-------求解答,十分感谢
- 请问下,怎么修改jnu的编码格式
2设置一个布尔值,判断进度在是否在状态栏,然后进行dialog的显示隐藏
关于第二点的点击事件
在手机的状态栏中显示自定义view,其中比较麻烦的是按钮事件,以下为设置和响应按钮事件的操作
//声明一个广播来接收事件并响应
BroadcastReceiver onClickReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(STATUS_BAR_COVER_CLICK_ACTION)) {
//在这里处理点击事件
}
}
}; //设置按钮事件
IntentFilter filter = new IntentFilter();
filter.addAction(STATUS_BAR_COVER_CLICK_ACTION);
//filter.addAction(STATUS_BAR_COVER_CLICK_ACTION2); 若不止一个按钮
registerReceiver(onClickReceiver, filter); Intent buttonIntent = new Intent(STATUS_BAR_COVER_CLICK_ACTION);
PendingIntent pendButtonIntent = PendingIntent.getBroadcast(this,0,buttonIntent,PendingIntent.FLAG_UPDATE_CURRENT);
mRemoteViews.setOnClickPendingIntent(R.id.btn, pendButtonIntent);
//Intent buttonIntent = new Intent(STATUS_BAR_COVER_CLICK_ACTION2);
//PendingIntent pendButtonIntent2 = PendingIntent.getBroadcast(this,0,buttonIntent2,PendingIntent.FLAG_UPDATE_CURRENT);
//mRemoteViews.setOnClickPendingIntent(R.id.btn2, pendButtonIntent2);