I am making a app for a android phone development company. I need to run the app in the background there should not be any user interaction like google play service. So I made a application and placed it in the "system/app" so that user can't uninstall the app but I need to open the application to run the service in the background how can I skip that.
-
This problem is already solved? – Majkl Oct 30 '15 at 08:49
-
My requirement was to open a application at boot load WITHOUT A SINGLE TIME LUNCHING THE APP – A J Oct 30 '15 at 08:56
-
Everybody given ans how to open the app at bootload but if you have not lunched the application for the first time bootload will never be called. – A J Oct 30 '15 at 08:58
-
Yes, I solved a similar problem. I created a BootBroadcastReceiver and launches the application from visual studies. Then i closed it. Then i tried turn off and on device but intnent did not come and the application does not start. I must after installing app close it and then run again on the device, and then it bootRecevier works. I think it's a problem with development time, but if you publish app through Google Play and standard installed, then should booRecevier work. Check it out (i am not in the deploynment phase) – Majkl Oct 30 '15 at 09:36
-
I don't have any option to upload it in google play because it a product – A J Oct 30 '15 at 10:08
-
well, when I get to the deployment phase, I'll know if it is ok (I hope it will be). – Majkl Oct 30 '15 at 11:40
-
Have you got solution for this. If yes, then pls post your solution I had similar requirement, Thanks. – Vindhya Pratap Singh Oct 20 '16 at 08:19
-
Not possible with out rotted device – A J Oct 20 '16 at 08:21
-
Hi bumba , I got solution First thing if you application is system then you they your app will be in active state. You can use Boot_complete_receiver for launching service. Or If your app don't have any launch activty then it will work it is active state. you don't need to open app. http://stackoverflow.com/questions/40149797/auto-start-service-after-booting-device-even-app-not-opened-atonce-android – Vindhya Pratap Singh Oct 20 '16 at 10:13
3 Answers
Look here: Android BroadcastReceiver on startup - keep running when Activity is in Background
Once you have broadcast receiver that is being called when system boots, you should start sticky service. Look here: START_STICKY and START_NOT_STICKY
That way your application will be started on system each system boot.
I think you should register for some BroadcastReceivers, so it will start yous app. You can use for example the boot_completed
action so like this:
public class Autostart extends BroadcastReceiver
{
public void onReceive(Context arg0, Intent arg1)
{
Log.i("Autostart", "**********started************");
}
}
and the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pack.saltriver" android:versionCode="1" android:versionName="1.0"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".Autostart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
</manifest>
but you can use a different type, you just need to modify the name of the intent . Here is the list of all BroadcastReceiver Intent.
There are many intent filter you can use fro ex- boot completed or Power plugged.
In both cases you can use broadcast receiver to to launch the active.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pack.saltriver" android:versionCode="1" android:versionName="1.0"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".tart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

- 1,941
- 3
- 21
- 34