0

want to open the setting of the device when i click on the home button in the device i tried this code but when the app start its open the device setting automatically

        @Override
    public void onAttachedToWindow() {
       super.onAttachedToWindow();
       this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 
       startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
    }

how to make this code open the setting of the device when the home key button clicked only ?

memo
  • 1
  • 4
  • 2
    You shouldn't (and can't, really) override a device's Home button. Why not just provide a Button to open the Settings? – Mike M. Apr 14 '14 at 15:18
  • i try to do something new in my app but i cant find it until now (the home key ) .. do you know the home key code ? i tried this on the return key and works ---> public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); } return false; } ---- but i want to control on the home key button not the return back key – memo Apr 14 '14 at 15:22
  • 1
    Your users will not be happy if you override the default Home button on their devices. I would go with Mike's suggestion above if I were you. –  Apr 14 '14 at 15:25
  • yes but the app including new idea and this movement will make the app looks new as the idea – memo Apr 14 '14 at 15:28

0 Answers0