11

How to make our app which is act like kiosk mode app( SureLock lockdown app). I have LG E400 rooted android phone Android 2.3.6. I want to develop app like Surelock what shold i need to develop such app.

Can anyone help me to develop such app on my own.

My requirements: Android device boots with my app. For this app all hardware buttons are disabled(Home, Back, Menu) similar to SureLock app.

tshepang
  • 12,111
  • 21
  • 91
  • 136
PrasadM
  • 211
  • 2
  • 4
  • 8
  • Both the accepted answer and the answer with the most upvotes **don't completely lock your application in kiosk mode**. There are duplicate questions on SO about this problem so I won't answer this one, but I have an answer here with pros and cons of different solutions: https://stackoverflow.com/a/43644803/2888763 – Trevor Halvorson May 22 '17 at 17:44

2 Answers2

28

Ok ... after hours of struggling with this my self and finding nothing on net worth while....(does not require rooting of phone)

Home button ::::

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

to handle home bottom...

Back button ::::

@Override
public void onBackPressed() {
    // We doing this too stop user from exiting app, normally.
    // super.onBackPressed();
}

For long press home button( recent app activity or google now) or recent app button ...

@Override
protected void onPause() {
    super.onPause();

    ActivityManager activityManager = (ActivityManager) getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE);

    activityManager.moveTaskToFront(getTaskId(), 0);
}

will need permission ...

<uses-permission android:name="android.permission.REORDER_TASKS" />
Clifford
  • 281
  • 3
  • 2
  • Warning ... this could potentially brick your phone ... I think...you should be alright as long as you have tick always allow your machine usb debugging...that way you can change the code and redeploy it from you machine. – Clifford Oct 22 '13 at 10:03
  • 1
    You can always boot into the bootloader using the hard keys and flash from there. It wouldn't be fun but it would put you in a safe distance from "brick" – Vaiden Nov 07 '13 at 10:49
  • 8
    users can remove the application from settings. because notification bar can open still by this way. – Selin Mar 19 '14 at 14:26
  • @Clifford This is creating a new activity every time. Is there a way to avoid creating new activity every time the home button is clicked. – amalBit Aug 13 '14 at 10:35
  • Great solution. I have implemented all sorts, when all that was required was this. – mwrf Oct 09 '14 at 14:22
  • 1
    what about the top menu? – user1532587 Jan 23 '15 at 06:21
  • Movetasktofront is undefined – Menna-Allah Sami Feb 18 '15 at 09:58
  • Exactly how will this intercept home long press? It seems it would just bring home screen to front on pause...(?) – JohnyTex Mar 24 '15 at 09:35
7

If your app acts like a home screen and you have no other home screen installed (or checked your app as default) it will start on boot and you won't be able to exit it. Unless you kill the task somehow, but that's not preventable.

Your app has to use the

android.intent.category.HOME

intent to be the first visible app on boot.

If you want some source you can look at Anderweb's ADW Launcher https://github.com/AnderWeb/android_packages_apps_Launcher

Dominic
  • 3,353
  • 36
  • 47
  • Thanks for the help. But how can i disable the buttons while my app is running. I mean disabling Hardware buttons functionality (Back, Home and menu buttons) – PrasadM Jan 11 '13 at 05:59
  • http://stackoverflow.com/questions/2000102/android-override-back-button-to-act-like-home-button Here's an example of the back button. You might have to catch the search button as well. The home shouldn't be a problem because your app will be the home app. – Dominic Jan 12 '13 at 15:24