Skip to content

Instantly share code, notes, and snippets.

@pfulop
Created February 11, 2017 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfulop/bde9a6600bca3e8743bea1b95977b2e5 to your computer and use it in GitHub Desktop.
Save pfulop/bde9a6600bca3e8743bea1b95977b2e5 to your computer and use it in GitHub Desktop.
public class NetworkChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
if(!isAppOnForeground((context))){
if(isInternet(context))
{
Intent serviceIntent = new Intent(context, MyTaskService.class);
context.startService(serviceIntent);
}
HeadlessJsTaskService.acquireWakeLockNow(context);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment