I am trying to override home key and full screen the acitiy using below code. locking of home key is working fine but it unable to hide notification bar (unable to full screen the activity).
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>
![out put of above code it cute the topside of layout as show in img. ][1]
i am also trying to setType using handler it full screen the activity but it could not override menu key. please help me.
Thanks in advance.
Try this code before setContentView(xml)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Hope, this will work for you.