您的位置:首页 > 移动开发 > Android开发

android 判断屏幕是否关闭

2012-06-26 14:41 786 查看
public void onCreate(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_SCREEN_OFF.equals(action)){ Log.d(TAG, "----------------- screen is off..."); } } };
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐