Android Question Dual Sim Phone

potman100

Active Member
Licensed User
Longtime User
I have a Dual sim phone, and I am trying to switch the data connection setting in code.

After lots of searching online I have found a way to enable and disable each sim card

B4X:
i.Initialize("android.intent.action.DUAL_SIM_MODE","")
i.PutExtra("com.android.phone.extra.slot", 2)
i.PutExtra("mode", 1)
p.SendBroadcastIntent(i)

By changing the mode I can

disable both cards = 0
enable card 1 = 1
enable card 2 = 2

This is working ok.

Now, using the following code :

B4X:
s.Initialize("android.intent.action.DATA_DEFAULT_SIM", "")
s.PutExtra("com.android.phone.extra.slot", 2)
s.PutExtra("simid", 2)
p.SendBroadcastIntent(s)

This I thought would enable data on sim 2, but using either

simid = 1 or 2

just disables the data connection, rather than making the data connection active on the selected sim.

I took the code from the following :

B4X:
Settings.System.putLong(getContentResolver(), "gprs_connection_sim_setting ", simN);
Intent localIntent = new Intent("android.intent.action.DATA_DEFAULT_SIM");
localIntent.putExtra("simid", simN);
sendBroadcast(localIntent);

I was not sure about this line

B4X:
Settings.System.putLong(getContentResolver(), "gprs_connection_sim_setting ", simN);

My thinking is if it can be disabled, it should be able to be assigned ?

Any Idea's

Regards

Potman
 

potman100

Active Member
Licensed User
Longtime User
3.82, just updated the java lib, so got it all running now, but still not working as hoped.

simN = 0

Still just disables the data connection.
 
Upvote 0
Top