我正在嘗試使用下面的代碼覆蓋Home Key和全屏幕Acitiy。主鍵的鎖定工作正常,但無法隱藏通知欄(無法全屏顯示活動)。當我使用onAttachedToWindow時無法進行全屏活動
public class ScreenLockDemo extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.screenlock);
}
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_BACK){
return true;
}
if(keyCode==KeyEvent.KEYCODE_HOME){
return true;
}
return super.onKeyDown(keyCode, event);
}
}
的AndroidManifest.xml:
<activity
android:name="com.antivirus.antitheft.ScreenLockDemo"
android:configChanges="touchscreen|keyboard|keyboardHidden|navigation|orientation"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
[出放上面的代碼可愛的展現在IMG佈局的頂面! ] [1]
我也嘗試使用它處理全屏活動的setType,但它不能超越菜單鍵。請幫幫我。
在此先感謝。
這將幫助:http://stackoverflow.com/questions/9369144/activity-doesnt-show-in-full-screen – 2014-05-30 14:27:14