Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Activity found to handle Intent { act=android.intent.action.DIAL }

I want to open my phone dialer .But it shows error. I have declared permissions for CALL_PHONE on Android Manifest and also declared class in Android Manifest.

case R.id.action_call:
Log.d("Action_call","INside Action call");
Intent dialer = new Intent(Intent.ACTION_DIAL);
startActivity(dialer);
return true;
like image 810
Loren Avatar asked Aug 28 '15 05:08

Loren


2 Answers

You don't need any permissions for ACTION_DIAL Intent. So remove CALL_PHONE permission from AndroidManifest.xml.

You have not pass any number to fire dial Intent.

Use tel: followed by the phone number as the value passed to Uri.parse():

Try this code.

 String number = "1234567890";
 Uri number = Uri.parse("tel:" + number);
 Intent dial = new Intent(Intent.ACTION_DIAL);
 dial.setData(number);
 startActivity(dial);

EDIT:

You can first check whether telephony is supported on device

private boolean isTelephonyEnabled(){
    TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY
}

I hope it helps!

like image 126
Rajesh Avatar answered Sep 28 '22 09:09

Rajesh


Use Uri to parse number..

Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:"+phone));  //String phone
startActivity(call);
like image 39
Iamat8 Avatar answered Sep 28 '22 08:09

Iamat8