I'm trying to run an app in background which tells me when the status of wifi is modified;
public class BackgroundJobs extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("BACKJOBS", "here we are");
wifiInfo wifiHandler = new wifiInfo(this);
// wifistatus checks if wifi is on or off, returning a boolean
if(wifiHandler.wifiStatus())
Log.i("BACKJOBS", "WIFI ON");
else
Log.i("BACKJOBS", "WIFI OFF");
return Service.START_NOT_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
//TODO for communication return IBinder implementation
return null;
}
}
In my MainActivity I start the service as follows:
startService(new Intent(this, BackgroundJobs.class));
and in AndroidManifest.xml:
<service android:name=".gestioneServizi.BackgroundJobs"/>
I start my app, I go back to my home pushing the home button, i switch on or off the wifi, but I don't see the logs "BACKJOBS".
Am i misunderstanding something or I'm working with the wrong method?