android 锁屏页

1监听锁屏广播

2收到广播后开启activity

3activity中oncreate代码


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
setContentView(R.layout.activity_musicscreen);
initViews();//初始化页面


//开启锁屏限制,使activity中控件可点击
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
keyguardLock.disableKeyguard();

//设置背景色透明
Drawable drawable = getResources().getDrawable(R.drawable.none);
this.getWindow().setBackgroundDrawable(drawable);
}

你可能感兴趣的:(android)