0

I am working on csipsimple version 1915. It work fine for android devices below 4.4.2 . To call somebody in local network I have this method

private void broadCastAndroidCallState(String state, String number) {
    //Android normalized event
    Intent intent = new Intent(ACTION_PHONE_STATE_CHANGED);
    intent.putExtra(TelephonyManager.EXTRA_STATE, state);
    if (number != null) {
        intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, number);
    }
    intent.putExtra(pjService.service.getString(R.string.app_name), true);
    pjService.service.sendBroadcast(intent,android.Manifest.permission.READ_PHONE_STATE);
}

But it does not work on android version 4.4.2. When I want to make a call it crashes. I have modified my code as follows

private void broadCastAndroidCallState(String state, String number) {
        // Android normalized event
        if(!Compatibility.isCompatible(19)) {
            // Not allowed to do that from kitkat
            Intent intent = new Intent(ACTION_PHONE_STATE_CHANGED);
            intent.putExtra(TelephonyManager.EXTRA_STATE, state);
            if (number != null) {
                intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, number);
            }
            intent.putExtra(pjService.service.getString(R.string.app_name), true);
            pjService.service.sendBroadcast(intent, android.Manifest.permission.READ_PHONE_STATE);
        }
    }

By modifying this my application does not crash but cant hear anything. Please help me with this.

code_geek
  • 163
  • 2
  • 11

1 Answers1

0

There are two way, first way you can set phone number in textview and set autoLink in textview. So, it's handle everything.

Second thing is that,

Intent callIntent = new Intent(Intent.ACTION_DIAL);          
callIntent.setData(Uri.parse("tel:"+phonenumber));          
startActivity(callIntent);
Krunal Indrodiya
  • 782
  • 2
  • 7
  • 19