解决方案 »
- 关于android4.0+长按Home键的操作
- Android http调用aspx,后台接收到的数据是乱码?
- 集成第三方apk软件不能使用,但是手动安装可以使用
- 学习记录
- android拍照预览,获取数据的问题
- 请问在edittext中,我想在edittext得到焦点和失去焦点时做一些事情该如何处理
- android frame动画在activity中自动播放问题
- 安卓怎么实现计算纪念日
- android popupWindow伪菜单背景半透明以及触摸事件的相关问题
- Android之Error: 'L' is not a valid file-based resource name character如何解决
- 请教 dex反编译的问题
- android下有没有sd卡的自动运行机制,一插卡就自动运行卡里面的安装程序
public void onCreate(final Bundle savedInstanceState) {
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
registerReceiver(mBatInfoReceiver, filter);
private final BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();
if(Intent.ACTION_SCREEN_ON.equals(action)){
Log.d(TAG, "screen is on...");
}else if(Intent.ACTION.equals(action)){
Log.d(TAG, "screen is off...");
}
}
}; 按照1楼给出的intent,监听广播
解锁广播和ACTION_SCREEN_ON 没有关系。不过ACTION_USER_PRESENT应该有用,但是我没有试,现在问题解决了,我是通过修改\frameworks\base\policy\src\com\android\internal\policy\impl\LockScreen.java 在里面添加了一个解锁的广播。目前还没有找到锁屏时的广播应该在那里发(有些机器是不锁屏的,我用的“智器”就是这种情况)。
谢谢你的回答。