What is the best approach to autostart an Android application on a dedicated device?

I am new to Android programming, and I am working on an application that will provide an interface to the device. The Android device on which the application will run will be connected to the device and will only be used to control the device. The application I'm working on will be the only application that ever runs on a dedicated Android device.

One of the requested features is to automatically launch the application when the Android device starts. I implemented this function by detecting the intention ACTION_BOOT_COMPLETED, as described in this thread . However, I saw an alternative approach recommended to make the application a home screen, as described in this topic .

I understand that implementing the autostart function by detecting ACTION_BOOT_COMPLETED, as I have already done, may not be the best approach for Android applications in general. But, as already mentioned, in my case, the application that I am developing will be the only application that has ever been used on a device. Given that the approach that I take is reasonable? Or is there a better way to implement autostart?

Please note that one of the considerations is the ease of setting up your Android device. The approach I'm taking will require one manual step to launch the application for the first time. But it seems like a manual step will also be required if I take an alternative approach to creating an application on the home screen, so there will be no advantage in adopting such an approach in this regard.

Thank you for your help!

EDIT: I tried to configure the application as the main screen by changing AndroidManifest.xml, as Holmes suggested below. Here is what I have found so far in my comparison of the two approaches: (1) The code is much simpler using the home screen approach, which requires only minor AndroidManifest.xml settings, and not more significant changes and an additional BroadcastReceiver class, (2) Installation procedure a bit more complicated using the approach to the home screen, since you need to do more than just open the application, but not significantly more complicated. (3) The approach to the home screen is better for restricting the user to one application, since he cannot use the default home screen to launch other applications. Based on these results, I will probably use the approach to the home screen.

+4
source share
3 answers

I am currently working on a special application, and I can provide you with some details that may be useful.

Listening to ACTION_BOOT_COMPLETED is the same as waiting for the device to complete the download, launch it on your home application, and then launch the application.

I believe that you do not want your end customer to see the home screen, and neither do I.

However, you can define your application as a HOME application for an Android device. Once it completes the download, it will be the first visible application on the go.

 <activity....> <!-- Put this filter inside the activity you want to make the Home screen --> <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> </activity> 

Note. If you need your device to boot automatically when you turn on a specialized device, try removing the battery from Android and connecting it directly. This is not related to your question, but, as I see it, it may be useful in your project.

+2
source

Based on your question, I would make this application run as a launch (aka the start screen). In this case, listening to ACTION_BOOT_COMPLETED not necessary if the application is installed as a launch device.

+2
source

For your needs, ACTION_BOOT_COMPLETED is very good. Remember that NEEDS applications are launched manually at least once for ACTION_BOOT_COMPLETED to work with devices with 3.0 +

0
source

All Articles