I am willing to detect when the device is on WIFI to trigger a local notification.
Most of answers include having a BroadcastReceiver listen for wifi.STATE_CHANGE. However someone noted that since Android 5.0 JobScheduler offers a more efficient way of doing this:
JobInfo uploadTask = new JobInfo.Builder(mJobId,
mServiceComponent /* JobService component */)
.setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED)
.build();
JobScheduler jobScheduler =
(JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(uploadTask);
My app still suports 4.1, So I'm not sure if there is any way I could add the JobScheduler for versions 5.0+, and leave the static broadcast receiver in the Manifest only for the lower versions.