I have a dual SIM (slot 0 and slot 1) phone. I have the phonestatelistener in my service. This listener receives the callback only when the SIM in the sim slot 0 receives the call. This listener is not getting callback when a call comes for SIM in SIM slot 1.
I have swapped the SIM and confirmed that irrespective of the SIM the phonestatelistener getting callback for the SIM in the SIM slot 0 only.
I couldn't' understand the issue.
Please let me know what could be the problem
Phone model samsung galaxy s duos 2 (GT-S7562) OS jelly bean 4.2.2
Homeservice.java
public class Homeservice extends Service{
TelephonyManager telephonyManager;
PhoneStateListener listener;
@Override
public void onCreate() {
// Get the telephony manager
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// Create a new PhoneStateListener
listener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
//finish something
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
//do somethings
break;
case TelephonyManager.CALL_STATE_RINGING:
break;
}
}
};
// Register the listener wit the telephony manager
telephonyManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}
Manifest.xml
<service
android:name="com.kabil.homeservice"
>
</service>