Detect target phone number on incoming call is it for SIM 1 or for SIM 2 for Android 29+?

554 views Asked by At
  1. I have tried all of the stack overflow solutions but it didn't work, all solutions are outdated
  2. I tried both below codes but it always return the -1

int slot = intent.getExtras().getInt("slot",-1)

int slot = intent.getExtras().getInt("simId", -1)

1

There are 1 answers

1
Tariq Hussain On
val accounts = telecomManager.callCapablePhoneAccounts

if (accounts.size > 1) {

                accounts.forEachIndexed { index, account ->
                    if (account == CallManager.call.last()?.details?.accountHandle) {

                        val phoneAccount = telecomManager.getPhoneAccount(account)
                        val label = phoneAccount.label.toString()

                        val img: Drawable =
                            resources.getDrawable(sims[index], theme)
}

Try using this method with telecomManager you can find the sim on which you are receiving call.