use getApplicationContext() when storing a passed in Context
getApplicationContext() returns the Context of the application, which is guaranteed to have the same life as the app itself. Other Contexts, like an Activity, might go away during runtime.
This commit is contained in:
parent
09fb7969b4
commit
09db3524cf
@ -73,7 +73,7 @@ public class LocalRepoManager {
|
||||
}
|
||||
|
||||
private LocalRepoManager(Context c) {
|
||||
context = c;
|
||||
context = c.getApplicationContext();
|
||||
pm = c.getPackageManager();
|
||||
assetManager = c.getAssets();
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(c);
|
||||
|
@ -27,7 +27,7 @@ public class LocalHTTPD extends NanoHTTPD {
|
||||
super(FDroidApp.ipAddressString, FDroidApp.port);
|
||||
this.logRequests = false;
|
||||
this.webRoot = webRoot;
|
||||
this.context = context;
|
||||
this.context = context.getApplicationContext();
|
||||
if (useHttps)
|
||||
enableHTTPS();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user