[Q] How select preferred network operators automatically?


I want to select preferred network operators automatically from device.

After I search for it, I found following:

final int EVENT_AUTO_SELECT_DONE = 300; Message msg = mHandler.obtainMessage(EVENT_AUTO_SELECT_DONE); phone.setNetworkSelectionModeAutomatic(msg);

So I need an instance of class "Phone". I tried this:

String phoneFactoryName = "com.android.internal.telephony.PhoneFactory"; String phoneName = "com.android.internal.telephony.Phone"; Class phoneFactoryClass = Class.forName(phoneFactoryName); Class phoneClass = Class.forName(phoneName); Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone"); Object phoneObject = getDefaultPhone.invoke(null);

But the method "getDefaultPhone" can only called by looper.

Next I tried this:

String phoneAppName = "com.android.phone.PhoneApp"; Class phoneAppClass = Class.forName(phoneAppName); Method getInstanceMethod = phoneAppClass.getMethod("getInstance"); Object phoneObject = getInstanceMethod.invoke(null);

But I get a ClassNotFoundException.

Can anybody help me, please?

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by berry.harris
2 hours ago
Started by bergnaum.jody
Last post by axel.homenick
4 hours ago
Last post by frederik.denesik
33 minutes ago
Last post by elindgren
3 hours ago
Last post by demetris.kessler
1 hour ago
Started by kiley16
Last post by grady.ayana
3 hours ago
Last post by runolfsson.amir
3 hours ago
Last post by ben.collier
28 minutes ago
Last post by ehegmann
44 minutes ago
How do I fix
Started by zgoodwin
Last post by willms.alexandro
3 hours ago