Fix HotspotService force finished on clicking stop server

This commit is contained in:
Adeel Zafar 2019-08-07 16:11:42 +05:00
parent 0928d9c625
commit 681742fdb5
2 changed files with 4 additions and 6 deletions

View File

@ -23,7 +23,7 @@ public class WebServerHelper {
public static boolean isStarted;
int port;
private CoordinatorLayout coordinatorLayout;
ServerStateListener listener;
static ServerStateListener listener;
String TAG = WebServerHelper.this.getClass().getSimpleName();
public WebServerHelper(Context context) {
@ -47,6 +47,7 @@ public class WebServerHelper {
public static boolean stopAndroidWebServer() {
if (isStarted ) {
isStarted = false;
listener.serverStopped();
return true;
}
return false;

View File

@ -18,7 +18,6 @@ import androidx.core.app.NotificationCompat;
import org.kiwix.kiwixmobile.R;
import org.kiwix.kiwixmobile.main.MainActivity;
import org.kiwix.kiwixmobile.utils.Constants;
import org.kiwix.kiwixmobile.webserver.ServerStateListener;
import static org.kiwix.kiwixmobile.webserver.ZimHostActivity.ACTION_TURN_OFF_AFTER_O;
import static org.kiwix.kiwixmobile.webserver.ZimHostActivity.ACTION_TURN_ON_AFTER_O;
@ -31,12 +30,11 @@ import static org.kiwix.kiwixmobile.webserver.WebServerHelper.stopAndroidWebServ
public class HotspotService extends Service {
private static final int HOTSPOT_NOTIFICATION_ID = 666;
public static final String ACTION_STOP = "hotspot_stop";
public static WifiHotspotManager hotspotManager;
private static final String ACTION_STOP = "hotspot_stop";
private static WifiHotspotManager hotspotManager;
private BroadcastReceiver stopReceiver;
private NotificationManager notificationManager;
private NotificationCompat.Builder builder;
ServerStateListener serverStateListener;
String TAG = HotspotService.this.getClass().getSimpleName();
@Override public void onCreate() {
@ -117,7 +115,6 @@ public class HotspotService extends Service {
stopForeground(true);
stopSelf();
stopAndroidWebServer();
serverStateListener.serverStopped();
}
@Override