Search code examples
androidnetwork-programmingandroid-intentstart-activityandroid-wireless

Android Network Operator Settings Intent not working correctly


I am trying to open the Network Operator Settings view with the following code:

startActivity(new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS));

It works correctly on all the devices I could test, but on one of them (Alcatel One Touch Pixi, with Android 5.1) the Network Operator Settings view opens and automatically closes after that. I tried to see if the resolveActivity with the packageManager of that Intent returns null, but it does not, it opens the activity of network operator settings and then (for some reason) it automatically finishes.

Anyone can help me to fix this issue that only happens with some specific mobiles?


Solution

  • There's an alternative way to call the Network Settings menu:

    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.android.phone", "com.android.phone.MobileNetworkSettings"));
    startActivity(intent);
    

    This method works with Samsung devices but not sure about devices that you mentioned (since I'm specifying the name of the package and the activity class name).

    I think you can try and if works, you may add the proper conditions to use this code etc.