Periksa apakah layanan berjalan di latar belakang
// function that check if service is running in the background
private boolean isMyServiceRunning(Context context) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (BackgroundLocationUpdateService.class.getName().equals(service.service.getClassName())) {
Log.e("isMyServiceRunning?", true + "");
return true;
}
}
Log.i("isMyServiceRunning?", false + "");
return false;
}
Mohamed Boumlyk