Am running a simple app which will either On/Off Wifi when opened. Below is the code. I want the app to exit once the task is performed and so I have tried adding finish() or System.exit(0) at the end. It works correctly but when I check the overview button, I can still see the app in running state and I need to swipe it to stop the app. [I mean the third button which shows the running apps as thumbnails]
import android.content.Context;
import android.net.wifi.WifiManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
if(wifiManager.isWifiEnabled()){
wifiManager.setWifiEnabled(false);
}
else{
wifiManager.setWifiEnabled(true);
}
finish();
}
}