2

I want to create an app only for my phone, that runs all the time in background - and you should never stop that service from running. My goal is, that this app is sending the current location data to my computer at home - to get it back, when it has been stolen for example, or when I lost it.

The problem is, that it is not possible to start a service without having an activity and/or launcher icon (because the thief should not know this).

But: My phone is rooted, so is it possible to start the service anyway?

And also: When I place my APK into the /system/app partition, will the APK persist after doing a factory reset?

Ercksen
  • 668
  • 9
  • 23

1 Answers1

1

Yes, you can. Rooting your phone doesn't matter for what you want to do, and if anyone tried to factory reset your phone, your app will still not be deleted, if you put your apk in /system/app partition as you said. It will react as if it was a normal system app. But of course, you must also set the correct permissions for your app when moving it to the system folder to be able to work.

And to prevent the thief from knowing your app, you can just name your app with an ambiguous name and without an icon that describes what your app does, because your app will still be visible in your application manager from your phone settings. Along with that, you can do the following:

To create an app that does not have an icon in the Home Launcher, just remove the intent filter android.intent.category.LAUNCHER of your activity from the AppManifest.xml.

To implement your background application, it strongly depends on what you want to do. You can create a Service for long running tasks, BroadcastReceiver to react to specific events or activities with intent filters.

Edit:

In order to let your app work automatically, you must put your app in this folder /system/priv-app. This way, your app will be started everytime you boot your device.

Hussein El Feky
  • 6,627
  • 5
  • 44
  • 57
  • 1
    First of all, thanks for the fast reply. But usually, you need to start your app once before the boot event can be catched by it. How to deal with it? – Ercksen Aug 23 '15 at 17:27
  • 1
    Nice question, I am not an expert in android services, but I have searched a lot on how to start a service automatically without user interaction and found that that was not possible, you may need to check these links: http://stackoverflow.com/questions/990217/android-app-with-service-only and http://stackoverflow.com/questions/2127044/how-to-start-android-service-on-installation Maybe, you will have to create a simple user interface like this: http://android-codes-examples.blogspot.com/2011/11/running-service-in-background-on.html and make your app name and icon something ambiguous... – Hussein El Feky Aug 23 '15 at 18:01
  • 1
    This link might also be useful to you: http://stackoverflow.com/questions/8531926/how-to-start-a-service-when-apk-is-installed-for-the-first-time – Hussein El Feky Aug 23 '15 at 18:04
  • Those links are very interesting, but I got an idea maybee. The home screen/launcher, is always executed - it simply has to. Isn't it possibe to modify the apk or do some changes on the system partition that my apk is executed instead? Then I would make my service start the default launcher. – Ercksen Aug 23 '15 at 18:22
  • Actually, I have found a solution (maybe, still not sure). Check this link: http://stackoverflow.com/questions/10428510/how-to-start-launch-application-at-boot-time-android This will start your application when phone boots completely. – Hussein El Feky Aug 23 '15 at 18:29
  • Unfortunately, that is the problem I stated, this solution works after you have started your app once, and thats not an option for me :/ – Ercksen Aug 23 '15 at 18:31
  • Did you try that? According to what I read, it will start the app every time your phone is booted. Don't you want something like that? or you tried it and it didn't work? – Hussein El Feky Aug 23 '15 at 18:33
  • Yes, I did it exactly the same way. But anyway, I am gonna try to exploit the behaviour of the home screen apk. – Ercksen Aug 23 '15 at 18:38
  • Okay, best of luck to you. :) – Hussein El Feky Aug 23 '15 at 18:48
  • I found the solution! I just put my apk into /system/priv-app, and it worked perfect! Thanks for all the help! – Ercksen Aug 23 '15 at 19:13
  • No problem. Glad that helped! Please don't forget to mark my answer as correct if I helped you in any way... Thanks. :) – Hussein El Feky Aug 23 '15 at 19:15
  • I am gonna accept the answer, but it would be helpful if you would edit your answer and put my solution on top of it, as this is the way it works ;) – Ercksen Aug 23 '15 at 19:22
  • Done. You can also make any changes in my answer if needed. :) – Hussein El Feky Aug 23 '15 at 19:27