Oreo
This commit is contained in:
parent
b7bdee4d29
commit
12a79edb5b
@ -39,7 +39,7 @@
|
|||||||
android:name=".RestartService"
|
android:name=".RestartService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
<receiver android:name=".AlarmReceiver"/>
|
|
||||||
<receiver android:name=".RebootReceiver">
|
<receiver android:name=".RebootReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package com.flywithu.carnav;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
public class AlarmReceiver extends BroadcastReceiver{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
Intent in = new Intent(context, RestartService.class);
|
|
||||||
context.startForegroundService(in);
|
|
||||||
} else {
|
|
||||||
Intent in = new Intent(context, RealService.class);
|
|
||||||
context.startService(in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -257,7 +257,6 @@ feff0041c9c0c5b4bc18005a
|
|||||||
|
|
||||||
}
|
}
|
||||||
serviceIntent = null;
|
serviceIntent = null;
|
||||||
setAlarmTimer();
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
unregisterReceiver(mReceiver);
|
unregisterReceiver(mReceiver);
|
||||||
// if (mainThread != null) {
|
// if (mainThread != null) {
|
||||||
@ -291,16 +290,7 @@ feff0041c9c0c5b4bc18005a
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAlarmTimer() {
|
|
||||||
final Calendar c = Calendar.getInstance();
|
|
||||||
c.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
c.add(Calendar.SECOND, 1);
|
|
||||||
Intent intent = new Intent(this, AlarmReceiver.class);
|
|
||||||
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0);
|
|
||||||
|
|
||||||
AlarmManager mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
|
||||||
mAlarmManager.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user