Reputation: 373
I'm developing some android application .In application i want to disable home button .
So i tried to overide onAttachedToWindow
method, but the problem is i getting a error when start application.
Code :
@Override
public void onAttachedToWindow(){
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
Error :
java.lang.IllegalArgumentException: Window type can not be changed after the window is added. at android.os.Parcel.readException(Parcel.java:1603) at android.os.Parcel.readException(Parcel.java:1552) at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:912) at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:5415) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1581) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:606) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
any one have idea , what is the error of this code ?
Upvotes: 0
Views: 274
Reputation: 373
I found the answer for my question . in android Lolipop have startLockTask() funciton.this will pin your task. thak you all .
Upvotes: 1
Reputation: 2434
As I mentioned in other question, you are not able to disable or override, or even detect home button.
Set type of window you can only before setContentView()
.
Upvotes: 0