0

I am working on Android App which supports BLE devices.

  • In some mobile with Android 6. app is and ble service is killing by OS.
  • Is anyone having any idea how to keep running my app in background and after killing the app?

Using START_STICKY on service:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;}
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Parth
  • 1,908
  • 1
  • 19
  • 37
  • Could you post any code of your service? – Tomasz Czura Dec 20 '16 at 10:10
  • I am using START_STICKY in my service. updated in question. this is working fine for some mobile phone. – Parth Dec 20 '16 at 10:14
  • I researched in internet, i get to know this behaviour is due to doze mode feature in android 6. but I am not sure how to resolve this problem. – Parth Dec 20 '16 at 10:19
  • http://stackoverflow.com/questions/41217819/android-app-needs-not-to-be-wiped-from-memory?noredirect=1#comment69671013_41217819 – Mr.Popular Dec 20 '16 at 11:34
  • i am also trying to solve a pblm similar could you take a look at my quesiton which i have posted above – Mr.Popular Dec 20 '16 at 11:35

2 Answers2

0

Start your service in foreground by startForeground(), the in will be no affected by doze mode

Tomasz Czura
  • 2,414
  • 1
  • 14
  • 18
  • Thanks . But after killing app will it work?? service will run? – Parth Dec 20 '16 at 10:29
  • Still your service will be destroyed if someone clears recent apps if you try this.. and it will keep a notification in status bar in always – Mr.Popular Dec 20 '16 at 11:31
  • This is not working for me.. after killing app all things are clearing (notification, app, service) and service is not restarting even though i am using as START_STICKY. – Parth Dec 20 '16 at 13:24
0

I am trying to solve a problem similar to your. I think to have a Service always on you must acquire a wakeLock, see here: https://developer.android.com/reference/android/os/PowerManager.html

Nicola Mingotti
  • 860
  • 6
  • 15
  • i am releasing wakelock in on task removed callback but some time my service is not restarting automatically when app gets kill. any clue on this ? – Parth Dec 20 '16 at 11:31
  • http://stackoverflow.com/questions/41217819/android-app-needs-not-to-be-wiped-from-memory?noredirect=1#comment69671013_41217819 can you take a look at my question and solve it ??? i – Mr.Popular Dec 20 '16 at 11:33