Android Question Problems with Android 11 and ICC

S.M.R

Member
Hello
in android 11 we cant get iccid and os block request.

i found link below that say solved this problem by below code

can help me that how can i use this code in B4A :

Java Code for get icc id in android 11:
TelecomManager tm2= (TelecomManager)getSystemService(Context.TELECOM_SERVICE);
  
Iterator<PhoneAccountHandle> phoneAccounts = tm2.getCallCapablePhoneAccounts().listIterator();
PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();

return phoneAccountHandle.getId().substring(0,19);

link : https://stackoverflow.com/questions/67905747/problems-with-android-11-and-icc
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Handle the READ_PHONE_STATE permission (manifest editor + runtime permission) and start with this code:
B4X:
Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim tm2 As JavaObject = ctxt.RunMethod("getSystemService", Array("telecom"))
    Dim PhoneAccounts As List = tm2.RunMethod("getCallCapablePhoneAccounts", Null)
    Log(PhoneAccounts)
 
Upvote 0

S.M.R

Member
Handle the READ_PHONE_STATE permission (manifest editor + runtime permission) and start with this code:
B4X:
Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim tm2 As JavaObject = ctxt.RunMethod("getSystemService", Array("telecom"))
    Dim PhoneAccounts As List = tm2.RunMethod("getCallCapablePhoneAccounts", Null)
    Log(PhoneAccounts)

i do but dont return iccid

can you help me for get iccid in android 11?

please help simple

thanks
 
Upvote 0

S.M.R

Member
What is the output of this code?

output :

(ArrayList) [ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}]


i need iccid that i can found every call item from what sim by check with subscription_id field in "content://call_log/calls"

subscription_id field in "content://call_log/calls" = iccid
 
Upvote 0

S.M.R

Member
Add this:
B4X:
For Each Account As JavaObject In PhoneAccounts
Log(Account.RunMethod("getId", Null))
Next

Thank you so much Erel ?
it work perfect?

i get iccid but i dont know every iccid for what sim card?
how can i found it?

and please say What other information can I get besides "getId" like SIM card operator name &...

thanks alot
 
Upvote 0
Top