I have a started service that is started from an activity of my application. I am using this service to play online radio (like TuneIn)
The problem is, when I lock down the phone;
- If my application is on screen (started and visible), service continues to run.
- If my application is stopped (hidden) or destroyed, service also stops running. But sometimes later it starts up again.
I checked TuneIn for this case, it runs in each situation.
How can I achieve this?
Edit:
I tried to use WakeLock but my case continues:
public void onCreate() {
...
pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RadyoService WakeLock");
wl.acquire();
super.onCreate();
}
public void onDestroy() {
wl.release();
super.onDestroy();
}
And also take the permission:
<uses-permission android:name="android.permission.WAKE_LOCK" />
Can you help me to locate the error that I've made?
Thanks.