P potman100 Active Member Licensed User Longtime User Aug 25, 2015 #1 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 Code: Copy 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 : Code: Copy 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 : Code: Copy 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 Code: Copy 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
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 Code: Copy 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 : Code: Copy 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 : Code: Copy 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 Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User Aug 25, 2015 #2 You can implement this line with JavaObject: Code: Copy Dim ctxt As JavaObject ctxt.InitializeContext Dim jo As JavaObject jo.InitializeStatic("android.provider.Settings$System").RunMethod("putLong", _ Array(ctxt.RunMethod("getContentResolver", Null), "gprs_connection_sim_setting", simN)) Upvote 0
You can implement this line with JavaObject: Code: Copy Dim ctxt As JavaObject ctxt.InitializeContext Dim jo As JavaObject jo.InitializeStatic("android.provider.Settings$System").RunMethod("putLong", _ Array(ctxt.RunMethod("getContentResolver", Null), "gprs_connection_sim_setting", simN))
Erel B4X founder Staff member Licensed User Longtime User Aug 25, 2015 #3 You are using an old version of JavaObject. Which version of B4A are you using? Upvote 0
P potman100 Active Member Licensed User Longtime User Aug 25, 2015 #4 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
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.