Restricting Android syncing to WIFi

android, android-networking, android-syncadapter

Solution

you can make check for wifi as

    ConnectivityManager cm = (ConnectivityManager) YourActivity.this.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();

    if(info.getType()==ConnectivityManager.TYPE_WIFI)
    {
        System.out.println("WiFi Connected");
    }
    else
    {
            System.out.println("WiFi not connected");
    }

and also add permission in manifest as

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Problem

I am new to Android and am trying to write a `SyncAdapter` - is it possible to restrict the `SyncAdapter` to only perform a sync when the network is WiFi (and not 3G etc.)?

Original source