Android restriction - 3g

Asked

Viewed 61 times

3

I want to restrict 3G access to a single domain (that of my system) to save employees 3G access. But if the employee access via WIFI can be all released (because there will be no extra cost). There’s some way to do it?

  • 2

    and a web system or and an app? You want to do this in the app that Voce built or Voce wants to set up android?

  • Preferably set up android... :)

1 answer

0

You can do it that way:

    private void setMobileDataEnabled(Context context, boolean enabled) {
        final ConnectivityManager conman = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final Class conmanClass = Class.forName(conman.getClass().getName());
        final Field iConnectivityManagerField = conmanClass.getDeclaredField("mService");
        iConnectivityManagerField.setAccessible(true);
        final Object iConnectivityManager = iConnectivityManagerField.get(conman);
        final Class iConnectivityManagerClass = Class.forName(iConnectivityManager.getClass().getName());
        final Method setMobileDataEnabledMethod = iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
        setMobileDataEnabledMethod.setAccessible(true);

        setMobileDataEnabledMethod.invoke(iConnectivityManager, enabled);
    }

And enter this section in your Manifest:

    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
  • Thanks! I’ll use this as Plan B in case I can’t set up android...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.