android – How to autosync Sqlite Database using services?-ThrowExceptions

Exception or error:
public class NetworkChangeReceiver extends BroadcastReceiver {

    private static final String LOG_TAG = "NetworkChangeReceiver";
    private boolean isConnected = false;

    public void onReceive(final Context context, Intent intent) {

        if (MyApplication.getInstance().isConnectedToNetwork(context)) {
            Log.v(LOG_TAG, "Now you are connected to Internet!");
            if (!MyApplication.getInstance().getBooleanFromSharedPreference(IS_SYNC_WORKING)) {
                MyApplication.getInstance().addBooleanToSharedPreference(IS_SYNC_WORKING, true);
                context.startService(new Intent(context, AutoSyncPendingWorkReport.class));
                context.startService(new Intent(context, AutoSyncImages.class));

        } else {
            MyApplication.getInstance().addBooleanToSharedPreference(IS_SYNC_WORKING, false);

The above code I wrote is running Android platform marshamallow but in some latest platform versions it does not run on it. ex. 28 version

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *