diff options
author | cyBerta <cyberta@riseup.net> | 2020-07-25 11:19:53 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2020-07-25 11:19:53 +0200 |
commit | 86a2a765b9b7bea005bafaad5a4489f06a151de3 (patch) | |
tree | 9b1697db01a331744bff5538b2b3cb4ebddcf931 | |
parent | a2af7f5c226db54442220779cef575d82d215485 (diff) |
fix memory leak
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java index 0a2e2538..890d3b67 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java @@ -22,6 +22,8 @@ import android.content.Intent; import android.os.Bundle; import android.util.Log; +import java.lang.ref.WeakReference; + import se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState; /** @@ -33,18 +35,18 @@ import se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState; */ public class ProviderApiSetupBroadcastReceiver extends BroadcastReceiver { - private final ProviderSetupInterface setupInterface; + private WeakReference<ProviderSetupInterface> setupInterfaceRef; public ProviderApiSetupBroadcastReceiver(ProviderSetupInterface setupInterface) { - this.setupInterface = setupInterface; + this.setupInterfaceRef = new WeakReference<>(setupInterface); } @Override public void onReceive(Context context, Intent intent) { Log.d(ProviderListBaseActivity.TAG, "received Broadcast"); - + ProviderSetupInterface setupInterface = setupInterfaceRef.get(); String action = intent.getAction(); - if (action == null || !action.equalsIgnoreCase(Constants.BROADCAST_PROVIDER_API_EVENT)) { + if (action == null || !action.equalsIgnoreCase(Constants.BROADCAST_PROVIDER_API_EVENT) || setupInterface == null) { return; } |