How to disable the home key
Use this method to disable the Home key in android @Override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); }
Use this method to disable the Home key in android @Override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); }
Following code works for me 🙂 HomeWatcher mHomeWatcher = new HomeWatcher(this); mHomeWatcher.setOnHomePressedListener(new OnHomePressedListener() { @Override public void onHomePressed() { // do something here… } @Override public void onHomeLongPressed() { } }); mHomeWatcher.startWatch(); import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.Log; public class HomeWatcher { static final String TAG = “hg”; private Context mContext; … Read more
well this is simple one to show back button actionBar.setDisplayHomeAsUpEnabled(true); and then you can custom the back event at onOptionsItemSelected case android.R.id.home: this.finish(); return true;