Этот коммит содержится в:
Anton Tananaev
2015-08-17 14:35:24 +12:00
родитель 0850ac09b0
Коммит 3e786e474d
2 изменённых файлов: 8 добавлений и 6 удалений
+4 -4
Просмотреть файл
@@ -25,10 +25,10 @@ public class AutostartReceiver extends WakefulBroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
if (sharedPreferences.getBoolean(MainActivity.KEY_STATUS, false)) { if (sharedPreferences.getBoolean(MainActivity.KEY_STATUS, false)) {
context.startService(new Intent(context, TrackingService.class)); startWakefulService(context, new Intent(context, TrackingService.class));
} }
} }
} }
+3 -1
Просмотреть файл
@@ -53,7 +53,9 @@ public class TrackingService extends Service {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
AutostartReceiver.completeWakefulIntent(intent); 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);