start/stop Local Repo from any Activity
This forces the use of the Application's Context, so we can be sure the webserver will run as long as FDroid is running. It also checks to make sure whether the webserver is running before trying to start it.
This commit is contained in:
parent
7401366ac9
commit
2256cd00e1
@ -301,14 +301,17 @@ public class FDroidApp extends Application {
|
||||
};
|
||||
|
||||
public static void startLocalRepoService(Context context) {
|
||||
context.bindService(new Intent(context, LocalRepoService.class),
|
||||
if (!localRepoServiceIsBound) {
|
||||
Context app = context.getApplicationContext();
|
||||
app.bindService(new Intent(app, LocalRepoService.class),
|
||||
serviceConnection, Context.BIND_AUTO_CREATE);
|
||||
localRepoServiceIsBound = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopLocalRepoService(Context context) {
|
||||
if (localRepoServiceIsBound) {
|
||||
context.unbindService(serviceConnection);
|
||||
context.getApplicationContext().unbindService(serviceConnection);
|
||||
localRepoServiceIsBound = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user