register Network receiver in code (SDK28)
This commit is contained in:
parent
c7c8aea65c
commit
bec6d99036
|
@ -124,14 +124,6 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Network change local receiver -->
|
||||
<receiver android:name=".receivers.NetworkChangeReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps;
|
|||
import android.app.Application;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
|
@ -88,6 +90,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
||||
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.utils.ActivityMonitor;
|
||||
|
@ -294,6 +297,11 @@ public class MainApp extends Application {
|
|||
this.timeDateOrTZChangeReceiver = new TimeDateOrTZChangeReceiver();
|
||||
this.timeDateOrTZChangeReceiver.registerBroadcasts(this);
|
||||
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION );
|
||||
registerReceiver(new NetworkChangeReceiver(), intentFilter);
|
||||
}
|
||||
|
||||
public static String gs(@StringRes int id) {
|
||||
|
|
|
@ -24,8 +24,6 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
|
||||
private static EventNetworkChange lastEvent = null;
|
||||
|
||||
public static final NetworkChangeReceiver instance = new NetworkChangeReceiver();
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
EventNetworkChange event = grabNetworkStatus(context);
|
||||
|
|
Loading…
Reference in a new issue