I have an android application that contains only a service, no activities at all.
Is it possible such an application to be started at bootup automatically?
I have read http://blog.gregfiumara.com/archives/82 where it is described how to do it, but it does not work (at least on my side) if there is no activity that is launched after I install the apk.
So this application should run from bootup in the background and should provide periodically CPU usage data on a network.
Is there another way to do it, but without activity be shown?
Related
I am developing an application for a business entity. That application should run in the background in every employees' mobile phone. Employees are mostly salesman. The application basically detects location changes and suggest the salesman where they might visit. A kind of reminder application. It also lets other salesmen see where are their teammates.
Right now I am using a foreground activity and it works fine till the system forcefully doesn't kill the service or the phone doesn't reboot due to manual activity or battery discharge.
Ones the application is closed, as of now, the managers in the firm needs to call salespeople to turn on the application once, as on application start it automatically turn on its foreground service. But this is really an extra burden on the management team which can be automated.
I am ok to have any settings based or code based solution. One solution is to root the phones of salespeople and install some extra utility app or write the code based on root APIs, but this will be too much for this simple task.
THe permission RECEIVE_BOOT_COMPLETED was not added properly in the manifest. After adding the permission it worked calmly. In on receive method of the broadcast receiver, I am starting the foreground service.
At the moment, the best way is to use WorkManager https://developer.android.com/topic/libraries/architecture/workmanager/ Yes, it still alpha, but works very good.
From other side, you could work on automating the task "managers in the firm needs to call salespeople to turn on the application once". I mean, an app/backend could automatically call the salesman (with some pre-recorded message) or send SMS to them.
I have to develop an Android App that starts a service on boot. I have the privilege of creating even a new service in framework for it. But before that I have two question so this might be possible without going to framework.
Can an app (service only) signed with system keys be launched without an app launcher and start on boot without any activity ?
This is really another way of asking the first question : Can an app signed with system keys start for the very first time with BOOT COMPLETED broadcast intent ? I am aware that this is not possible for apps in user app space
Further documentation on the topic can be found here
I have followed the tutorial here :
http://blog.sptechnolab.com/2011/09/14/android/starting-an-android-service-after-boot/
about creating a service, which is activating after boot of Android.
Anyway It practically never started.
I found in here : How to start a Service when .apk is Installed for the first time
that it is not anymore possible since Android 3.0+.
My question is :
How to start a boot service once installed ?
but how to start manually a service, since it does not have any visual elements ?
Add "visual elements", in the form of an activity.
You need an activity anyway, for:
Settings for managing the behavior of this service
Help and instructions for getting support
License agreement
So, write the activity. After the user has launched your activity, your manifest-registered BroadcastReceivers, such as your BOOT_COMPLETED receiver, will work again on Android 3.1+ devices.
In lates android versions you can launch on boot only when user manually started application.
The "service" here is different form one of the application components "service" in Android. I mean that people can not see the app icon in launcher, and, the can not see the app in the program manager in Android.
The most important is that I don't want the user notice the existence of the app.
Is that possible? Is it a "service" in Linux?
Without ROM modifications, you can't make a linux service. I will tell you what you CAN do.
First, your requirements
Not see the app icon in launcher: This can be done by simply not having an activity that supports the ACTION.MAIN and CATEGORY.LAUNCHER intents.
Not see the app in program manager: Unfortunately for you (but fortunately for all users) you can't get around this with a normal application.
Have a service run "all the time": The best you can do here is start a foreground service upon boot of the device. This will cause a notification to be in the users notification bar, but its really the best you can do on stock phones.
I am successfully able to start my Android app automatically on boot using BroadcastReceiver with an intent-filter BOOT_COMPLETED. In my onReceive method, I start the launcher activity for my application.
However, I don't want this application to be in the foreground on boot, but I do want it to be on the activity stack. Is there a way to still have the home screen show up on boot, but also have my application starts up. (I don't think I want to use a Service, because my application has UI.)
Decision on weather you should or should not use Service in appliction is independent on weather it has UI or not. All "third party" apps have UI, there is little use of application without at least 1 activity.
So in your case, just use Service.