private void ScreenSaverMethod() {
// 关闭系统屏保
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
mKeyguardLock = mKeyguardManager.newKeyguardLock("");
mKeyguardLock.disableKeyguard();
// 注册receiver:
BroadcastReceiver mMasterResetReciever = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
try {
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setClass(context, MyScreenSaver.class);
context.startActivity(i);
// finish();
} catch (Exception e) {
Log.i("Output:", e.toString());
// e.printStackTrace();
}
}
};
registerReceiver(mMasterResetReciever, new IntentFilter(
Intent.ACTION_SCREEN_OFF));
}
mainfest.xml 配置 <uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
屏保在真机上怎么运行不起来啊,
求解啊,在模拟器上按电源键能用起来,,那在真机上,屏幕暗下来了,就没有反映了