Disable Android home, back and active apps buttons

Written by pradyumnadoddala | Published 2016/05/10
Tech Story Tags: android-app-development | android

TLDRvia the TL;DR App

Before you get totally into this post, I would like to warn you regarding the use of these functionalities, because they aren't user-friendly and Android Play Store wouldn’t approve of these unless you have a very strong reason.

Photo by Suika Ibuki on Unsplash

Active Apps/ Reorder Apps button

Add the following permission to AndroidManifest.xml

<uses-permission android:name="android.permission.REORDER_TASKS" />

The following to the Activity

@Overrideprotected void onPause() {super.onPause();

    ActivityManager activityManager = (ActivityManager) getApplicationContext()  
            .getSystemService(Context.ACTIVITY\_SERVICE);  

    activityManager.moveTaskToFront(getTaskId(), 0);  

}

Home Button

<category android:name="android.intent.category.LAUNCHER" /><category android:name="android.intent.category.HOME" /><category android:name="android.intent.category.DEFAULT" />

Back Button

@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {// Do nothing or catch the keys you want to block}

References

Home button disable_I do know that it is ill advice to take control of the HOME button for users. But I'm developing a android lockdown…_stackoverflow.com

If you’ve reached this, you’ve made it!! Have a great day!

Clap away if this helped you out. It encourages me to write more posts. And thanks for the support.

Prady | @pradyumna_d | “File Your Cryptocurrency Taxes Using BearTax!”


Published by HackerNoon on 2016/05/10