android: Fix launching on device boot
This commit is contained in:
parent
793a12d58d
commit
3d8e285e2b
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue