'Detect target phone number on incoming call is it for SIM 1 or for SIM 2 for Android 29+?
- I have tried all of the stack overflow solutions but it didn't work, all solutions are outdated
- 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)
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tariq Hussain |