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

10,096

Solution 1

Finally I got the solution using this code. Hope it should helpful for everyone who wants to handle Dual SIM phones. Its working fine for me.

Please add below codes in your BroadcastReceiver class:

public class IncomingCallInterceptor extends BroadcastReceiver {
@Override
    public void onReceive(Context context, Intent intent) {
    String callingSIM = "";
    Bundle bundle = intent.getExtras();
    callingSIM =String.valueOf(bundle.getInt("simId", -1));
    if(callingSIM == "0"){
        // Incoming call from SIM1
    }
    else if(callingSIM =="1"){
        // Incoming call from SIM2
    }
    }
}

Solution 2

add below codes in your BroadcastReceiver class.

public class IncomingCallInterceptorReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String callingFromSIM = "";
Bundle bundle = intent.getExtras();
callingFromSIM =String.valueOf(bundle.getInt("simId", -1));
if(callingFromSIM == "0"){

    // Incoming call from SIM1 Card

}
else if(callingFromSIM =="1"){

    // Incoming call from SIM2 Card 

}

}

}
Share:
10,096
Jebasuthan
Author by

Jebasuthan

Over 10 Years of experience as a Front End Engineer and Mobile App Developer with rich knowledge in Javascript, Vue, React, React Native, Angular, HTML5, CSS3 and Android. Ability to develop unique, cutting edge applications for Web Application, Android, iPhone and Windows 8. Passionate to update my knowledge and skills through continuous self learning and challenging work nature. Skill Sets: • Programming Languages : C#, Java • Scripting Languages : Vue, React, React Native, Angular 12, JavaScript, JQuery, Sencha Touch, HTML5, CSS3, LESS, SASS, Backbone, Handlebar, Node, MongoDB, MEAN Stack, MERN Stack, Karma, Jasmine, Grunt, Gulp • Operating Systems : MacOS, Microsoft Windows, Ubuntu • Subject of Exposure : Vue, React, React Native, Android, HTML5, Angular 12, Sencha Touch, PhoneGap • Database : MS-SQL, MYSQL, PostgreSQL, MongoDB

Updated on June 15, 2022

Comments

  • Jebasuthan
    Jebasuthan almost 2 years

    I have an Android phone with 2 SIM card and I want to detect the target of the incoming call — is it for SIM 1 or for SIM 2. Is it possible to get the target number from call info?