java - Window type can not be changed after the window is added -


i'm trying make custom lock screen. so, there need not allow user press home button. in beginning write

public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate); setcontentview(r.layout.lock_screen);  getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on                     |windowmanager.layoutparams.flag_show_when_locked); 

then override onkeydown

 @override public boolean onkeydown(int keycode, android.view.keyevent event) {  if ((keycode == keyevent.keycode_volume_down)||(keycode == keyevent.keycode_power)||(keycode == keyevent.keycode_volume_up)||(keycode == keyevent.keycode_camera)) {     //this can stuff     return true; //because handled event } if((keycode == keyevent.keycode_home)){      return true; }  return false;  } 

here override onattachetowindow

 @override public void onattachedtowindow() {     this.getwindow().settype(windowmanager.layoutparams.type_keyguard_dialog);     super.onattachedtowindow(); } 

but it's giving me error illegalargumentexception: window type can not changed after window added. mistake?

how can handle home button?

there no "good" way handle home button "do nothing". have 2 options may or may not enough you:

  1. create own home launcher. users must select app home launcher.
  2. you create service add view window , gets plastered on top of else. see previous answer here "displaying" webview in service: android: using webview outside activity context. need modify params fill screen , fix windowmanager.layoutparams.flag_not_touchable use right flags allow clicks. won't block home button disable it's functionality. lastly, might not work on android 5.0+ status bar's dropdown may overlay window.

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -