I want to let part of the app running even if the app terminated. I know how to let it run in the background, but that will not work if the app terminated. What I can do for the part of code I want to let it work even if the app terminated?
Asked
Active
Viewed 484 times
0
-
Using ADB with commandline [http://stackoverflow.com/questions/7076240/install-an-apk-file-from-command-prompt](http://stackoverflow.com/questions/7076240/install-an-apk-file-from-command-prompt) – Jayakrishnan Nov 27 '16 at 12:18
-
I find your title and description not matching, can you elaborate more? thankyou – Enzokie Nov 27 '16 at 12:23
-
I have installed the apk in my phone, but I want to make a part of the code running even if I close the app for ex. each o'clock the app save something in local database. notice that the service is not the solution because the service work when the app in background not when the app closed. I need something work even if the app closed – Saeb N. Salah Nov 27 '16 at 15:26
1 Answers
0
If you already have a build to your project, in your app's folder you will have an apk file witch you can install it on the device without starting Android Studio.
Your apk location is: ProjectName\app\build\outputs\apk
From command line:
adb install example.apk

AndroidGorilllla
- 189
- 12
-
No No ... I don't mean that, I have installed the apk in my phone, but I want to make a part of the code running even if I close the app for ex. each o'clock the app save something in local database – Saeb N. Salah Nov 27 '16 at 12:23
-
Ok, I understand.. What you need is a Service. Here is an example of how to use a service : [link](http://www.vogella.com/tutorials/AndroidServices/article.html) – AndroidGorilllla Nov 27 '16 at 12:27
-
There are many ways in with to use a service, if you get stuck, let me know. – AndroidGorilllla Nov 27 '16 at 12:32
-
the service work when the app in background not when the app closed. I need something work even if the app closed ... – Saeb N. Salah Nov 27 '16 at 15:25
-
Services work even if you close the app. check this answer: http://stackoverflow.com/questions/9740593/android-create-service-that-runs-when-application-stops – AndroidGorilllla Nov 27 '16 at 20:17
-