Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I have to do to launch phone internet settings dialog?

I have tried to set mobile data. But it just worked for only SIM 1 .

public static void setMobileData(Context context, boolean isEnabled) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

    ConnectivityManager conman = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    @SuppressWarnings("rawtypes")
    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());

    Class[] cArg = new Class[2];
    cArg[0] = String.class;
    cArg[1] = Boolean.TYPE;
    Method setMobileDataEnabledMethod;

    setMobileDataEnabledMethod = iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", cArg);

    Object[] pArg = new Object[2];
    pArg[0] = context.getPackageName();
    pArg[1] = isEnabled;
    setMobileDataEnabledMethod.setAccessible(true);
    setMobileDataEnabledMethod.invoke(iConnectivityManager, pArg);
}

public static void setMobileData2(Context context, boolean isEnabled) throws NoSuchMethodException, ClassNotFoundException, IllegalAccessException, NoSuchFieldException, InvocationTargetException {
    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, isEnabled);
}

public static boolean setMobileData3(Context context, boolean isEnable) {
    boolean mobileDataAllowed = Settings.Secure.putInt(context.getContentResolver(), "mobile_data", isEnable?1:0);
    return mobileDataAllowed;
}

But now I just want to launch that default mobile selection Dialog . If you have Any idea to launch that dialog let me know.. thanks in advance.

.

like image 632
shobhan Avatar asked Dec 03 '15 13:12

shobhan


People also ask

How can I get Dialog internet settings?

To get Dialog internet APN settings dial #107#8#2#3#. For Dialog MMS APN settings dial #107#8#2#2#. For Dialog streaming APN settings dial #107#8#2#4#.

How do I manually enter mobile internet settings?

To enter internet settings manuallyFind and tap Settings → Network & Internet → Mobile network. Tap Access Point Names (APN), then tap the plus (+) sign and enter the access point name. Tap Name and enter the name of the network profile that you want to create → OK. Tap APN and enter the access point name → OK.

Why my Dialog Mobile data is not working?

Go to internet settings set USERNAME as dialog and APN as ppwap if postpaid set APN as dialogbb. Then change network mode to LTE and restart the device and check it. If not To check signal refer www.dialog.lk (coverage map) or contact dialog agent through 0777678678 WhatsApp number to get this done.


2 Answers

Multi SIM support is added in android lollipop 5.1 onwards only. Prior to that different phone manufacturers have their own custom implementation for supporting Multi SIM and respective settings. Hence if you are targeting for general solution it is not possible to achieve. Even on 5.1, there is no direct intent to launch this particular setting but using a hack you may achieve provided manufacturers should use only Google solution otherwise it will not work.

like image 144
siva Avatar answered Sep 25 '22 17:09

siva


You have to start intent for settings like this.

startActivityForResult(new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS), 0);

'Note' There are also settings of WIFI and more .Explore it the much you want. like this

android.provider.Settings.ACTION_WIFI_SETTINGS
like image 41
Arslan Ashraf Avatar answered Sep 25 '22 17:09

Arslan Ashraf