You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1003 B
Java
28 lines
1003 B
Java
package com.fox2code.mmm.background;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
|
|
import com.fox2code.mmm.MainApplication;
|
|
import com.fox2code.mmm.utils.io.net.Http;
|
|
|
|
public class BackgroundBootListener extends BroadcastReceiver {
|
|
private static final String BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
if (!BOOT_COMPLETED.equals(intent.getAction())) return;
|
|
if (!MainApplication.isBackgroundUpdateCheckEnabled()) return;
|
|
if (!Http.hasConnectivity()) return;
|
|
// clear boot shared prefs
|
|
MainApplication.getBootSharedPreferences().edit().clear().apply();
|
|
synchronized (BackgroundUpdateChecker.lock) {
|
|
new Thread(() -> {
|
|
BackgroundUpdateChecker.onMainActivityCreate(context);
|
|
BackgroundUpdateChecker.doCheck(context);
|
|
}).start();
|
|
}
|
|
}
|
|
}
|