This commit is contained in:
Max Kellermann 2023-12-27 12:33:14 +01:00
commit bd408cd627
3 changed files with 14 additions and 3 deletions

View File

@ -28,8 +28,8 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
}
}

View File

@ -44,6 +44,9 @@
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<service

View File

@ -8,11 +8,19 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
import java.util.Set;
public class Receiver extends BroadcastReceiver {
private static final Set<String> BOOT_ACTIONS = Set.of(
"android.intent.action.BOOT_COMPLETED",
"android.intent.action.QUICKBOOT_POWERON"
);
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Receiver", "onReceive: " + intent);
if (intent.getAction() == "android.intent.action.BOOT_COMPLETED") {
if (BOOT_ACTIONS.contains(intent.getAction())) {
if (Settings.Preferences.getBoolean(context,
Settings.Preferences.KEY_RUN_ON_BOOT,
false)) {