I am making a proprietary application for a company that will never release it on the Android Market (or the Play Store, in my opinion, now) in Ice Cream Sandwich (Android 4.0).
I need to disable Home so that users cannot maliciously remove the software or delete the data that the application captures. This latest version is the first to be written in 4.0, previous versions were written in 2.2 and 3.2.
To disable the Home button in 2.2, I connected the application as a home replacement, so the button just opened the application, but I canβt use this method anymore, since it somewhat prevents us from updating the application (we donβt want to allow the user to re-select the value by default, as this will delete the data.
Code to disable the "Home" button in 3.2:
@Override public void onAttachedToWindow() { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); }
and, in onCreate:
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE); lock.disableKeyguard();
But when I run the same code that worked on my tablet 3.2, it does not work on my tablet 4.0.
I was wondering if there is a new API or method that has 4.0 that will implement the same effect as in my version 3.2.
Thanks for any help or guidance.
Adam
adamacdo Apr 09 '12 at 18:12 2012-04-09 18:12
source share