Move startForeground to onCreate
Этот коммит содержится в:
@@ -34,6 +34,7 @@ public class TrackingService extends Service {
|
|||||||
|
|
||||||
private boolean foreground;
|
private boolean foreground;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.i(TAG, "service create");
|
Log.i(TAG, "service create");
|
||||||
@@ -43,19 +44,6 @@ public class TrackingService extends Service {
|
|||||||
trackingController.start();
|
trackingController.start();
|
||||||
|
|
||||||
foreground = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(MainActivity.KEY_FOREGROUND, false);
|
foreground = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(MainActivity.KEY_FOREGROUND, false);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public void onStart(Intent intent, int startId) {
|
|
||||||
if (intent != null) {
|
|
||||||
AutostartReceiver.completeWakefulIntent(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR && foreground) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR && foreground) {
|
||||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||||
@@ -77,6 +65,20 @@ public class TrackingService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void onStart(Intent intent, int startId) {
|
||||||
|
if (intent != null) {
|
||||||
|
AutostartReceiver.completeWakefulIntent(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user