4

Let me describe you what I want: I want to build a "master app" and set it so that when the phone is powered up, it immediately goes into the master app. The user can never exit this app (this will be used for something like parental control), and he can only launch other apps from within it.

Basically it will be like a "custom desktop".

I must stress out, it is important that this app never exits. As long as the phone is started, this is the only environment that the user has access to.

Now after I explained what I need, I will need your help to tell me what am I looking for. Is this some kind of "default launcher" that I keep hearing about? Or how is this called? How can I do it?

Thanks

Poovizhirajan N
  • 1,263
  • 1
  • 13
  • 29
Bogdan Alexandru
  • 5,394
  • 6
  • 34
  • 54
  • 2
    you can't do app will be never exit it's malware program and this functionality restricted android 4.0 to higher! – Stack Overflow User Jun 26 '13 at 08:53
  • I did with accessing bootupservice – Poovizhirajan N Jun 26 '13 at 09:00
  • 1
    I would say create a launcher app and make it default. While done tjhat you could control almost everything with the right permissions – Dediqated Jun 26 '13 at 09:36
  • @Dediqated: how to do that? – Bogdan Alexandru Jul 08 '13 at 13:23
  • I don't think you can start an app on boot for Android 4.0 or higher. If your app is active when the phone shuts down, the app will start on the next boot-up automatically. – DXM Jul 11 '13 at 17:46
  • @BogdanAlexandru just Google on how to create an Android launcher app, that's an app to show the homescreen. In there you could control what the users could see and use. We're not giving you every piece of code how to do that. Search and find out yourself. If not helpful enough, ask a new question with the specific problem. For example check out this question: http://stackoverflow.com/questions/4841686/how-to-make-a-launcher – Dediqated Jul 12 '13 at 11:57

4 Answers4

6

Add this into Manifest.

<receiver
            android:name=".Bootupclass"
            android:enabled="true"
            android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >

</receiver>

Bootupclass

public class Bootupclass extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        //write intent here 
    }

}
Poovizhirajan N
  • 1,263
  • 1
  • 13
  • 29
3

I need someone to give me the exact code needed to make the app:

Here Goes,

If you make an app as a launcher app, and if it is the ONLY launcher app within your system, it will of course be started when you switch on your device. And also when you click on the home button, since your app is the only launcher app within the system, the same would be started.

so ,

1) start on bootup 2) be the default action when pressing the home button (the "desktop")

could both be merged into 1.

You mentioned that your phone is rooted, So easiest way to achieve what you require would be to

1.Install your app with just these lines within the manifest. i.e within your first activity. Nothing else is required. (this would make your app as a launcher app)

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.HOME"/>
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

2.Un-install the default launcher application within your device.

anudroid
  • 163
  • 4
1

What is being asked in the question body is different from the question title.

Listening to BOOT_COMPLETED will do literally what is requested by title - give control to the application once when device is powered on or restarted.

It is not enough to achieve the real goal - to prevent user from exiting the application and reaching "normal" home screen - once user presses "exit" or "home", he will essentially leave your app. While you can intercept "Exit" button and prevent it from quitting your app, "home" button is not possible to block programmatically.

In order to make and app like parental control and prevent user from reaching unwanted apps you need to implement "custom home screen" or "custom launcher" (which is the same thing).

It is rather large topic, but this seems to be a good starting point: Android - creating custom launcher.

And because author insists on "exact code", to make your app to start instead of a home screen (after boot or pressing "home" button), you need the following in the manifest:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME"/>
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

After install, press "home" button - you will be given a choice of standard launcher or your app. Check "use as default" and select your app - from now on it will start instead of the normal home screen.

Beware, though, that there are few known issues with custom launchers. One is - you have to block access to settings, otherwise user can switch back to default launcher. Also, after your app is updated (i.e. you post new version) user will be asked what home screen to use and can choose default launcher.

Community
  • 1
  • 1
amoiseyev
  • 327
  • 2
  • 7
1

I must stress out, it is important that this app never exits This I believe is not possible.

From your requirement it seems that you require a MDM solution. Upwards of Android 2.2 device administration APIs have been available. Check out http://developer.android.com/guide/topics/admin/device-admin.html

The user will have to install your app and allow it to be a Device Administrator. (You can see currently available administrators from Setting -> Location and Security -> Device Administrator). Now as an administrator you can control features on device eg. disallow apps to be uninstalled, prevent installation of specific apps, disallow launch of specific apps. wipe device if security is breached etc. You can also prevent your app from being uninstalled.

There are apps available with such features. I can name Maas360 off the top of my head. Disclaimer: I haven't tried the device administration apis myself.

Srikant Sahay
  • 885
  • 6
  • 9