diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fa3e1501e1..df95cda596 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -57,7 +57,6 @@ android:exported="true"> - diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 7e7d0ea030..c0d517673f 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -175,6 +175,8 @@ public class MainApp extends Application { lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV)); lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE)); lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS)); + lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG)); + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java index f45ade6b32..f857166f7d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.os.Bundle; +import android.support.v4.content.LocalBroadcastManager; import org.json.JSONArray; import org.slf4j.Logger; @@ -11,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.Services.Intents; import info.nightscout.utils.SP; @@ -22,14 +24,22 @@ public class BroadcastMbgs { public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) { - if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; - Bundle bundle = new Bundle(); bundle.putString("mbgs", mbgs.toString()); bundle.putBoolean("delta", isDelta); Intent intent = new Intent(Intents.ACTION_NEW_MBG); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - context.sendBroadcast(intent); + LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent); + + if(SP.getBoolean("nsclient_localbroadcasts", true)) { + bundle = new Bundle(); + bundle.putString("mbgs", mbgs.toString()); + bundle.putBoolean("delta", isDelta); + intent = new Intent(Intents.ACTION_NEW_MBG); + intent.putExtras(bundle); + intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); + context.sendBroadcast(intent); + } } }