[Q] How select preferred network operators automatically?

Hallo,

I want to select preferred network operators automatically from device.

After I search for it, I found following:

Code:
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:

Code:
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:

Code:
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 ladarius61
5 hours ago
Last post by lee.bartoletti
12 minutes ago
Last post by ephraim89
58 minutes ago
Last post by pgleason
3 hours ago
Last post by wilma.blick
14 minutes ago
Last post by art.miller
2 hours ago
Last post by lynch.madilyn
2 hours ago
Last post by jackie.kerluke
4 hours ago
Last post by audie44
3 hours ago
Last post by auer.prudence
3 hours ago
Last post by barton.alayna
2 hours ago