Lookup service via application context to avoid memory leak
This commit is contained in:
parent
3cb8f27e49
commit
e9700b0627
|
@ -33,7 +33,7 @@ public abstract class Downloader implements Callable<Downloader> {
|
|||
|
||||
public final Downloader call() {
|
||||
WifiManager wifiManager = (WifiManager)
|
||||
ClientConfig.applicationCallbacks.getApplicationInstance().getSystemService(Context.WIFI_SERVICE);
|
||||
ClientConfig.applicationCallbacks.getApplicationInstance().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
WifiManager.WifiLock wifiLock = null;
|
||||
if (wifiManager != null) {
|
||||
wifiLock = wifiManager.createWifiLock(TAG);
|
||||
|
|
|
@ -279,7 +279,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
|||
final synchronized void acquireWifiLockIfNecessary() {
|
||||
if (shouldLockWifi()) {
|
||||
if (wifiLock == null) {
|
||||
wifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE))
|
||||
wifiLock = ((WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE))
|
||||
.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
|
||||
wifiLock.setReferenceCounted(false);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class NetworkUtils {
|
|||
Log.d(TAG, "Auto-dl filter is disabled");
|
||||
return true;
|
||||
} else {
|
||||
WifiManager wm = (WifiManager) context
|
||||
WifiManager wm = (WifiManager) context.getApplicationContext()
|
||||
.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wm.getConnectionInfo();
|
||||
List<String> selectedNetworks = Arrays
|
||||
|
@ -103,7 +103,7 @@ public class NetworkUtils {
|
|||
* Returns the SSID of the wifi connection, or <code>null</code> if there is no wifi.
|
||||
*/
|
||||
public static String getWifiSsid() {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo != null) {
|
||||
return wifiInfo.getSSID();
|
||||
|
|
Loading…
Reference in New Issue