0

I would like to perform network providers search on my dual SIM device. So far I've been doing so by opening the "Available networks" or the "Network operators" menu item in the "Network settings" page. I've been doing it using this intent:

intent.setComponent(ComponentName.unflattenFromString("com.android.phone/.NetworkSetting"));

This opened the right activity directly, and automatically started searching for the available networks.

However, I'm on a dual SIM device right now, and whenever I open that activity by the intent above, It is opened on the "SIM2" tab of the activity, and hence I receive an error searching for available networks (SIM2 is empty, but it doesn't matter, because I want that functionality for SIM1). Is there any way to select which SIM to open the activity under? or a proper way to open the needed activity for searching networks on the main SIM?

I have been searching and it's not a very common thing, so nothing was found actually.

Hummus
  • 559
  • 1
  • 9
  • 21

1 Answers1

0

This code works for my China A918 DualSim Android Phone:

Intent intent = new Intent();
intent.setClassName("com.android.phone", "com.mediatek.settings.MultipleSimActivity");
PackageManager packageManager = getPackageManager();
// check if intent is available on device:
List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
    // set Intent to start after SIM card selection:
    intent.putExtra("TARGET_CLASS", "com.android.phone.NetworkSetting");
    intent.putExtra("ITEM_TYPE", "PreferenceScreen");
} else {
    // run default android network settings intent
    intent.setClassName("com.android.phone", "com.android.phone.NetworkSetting");
}
startActivity(intent);

In Android DualSim Phones you need to run different Intent to enter NetworkSettings, because when two SIM cards are inserted, you should have ability to choose first or second card.

In my case this is com.mediatek.settings.MultipleSimActivity. If it wont work, check in ADB logs which Intent is started when enter in "Available networks" through android system Setting

mdabrowski89
  • 21
  • 1
  • 4