android – No activity found to handle intent action.dial-ThrowExceptions

Exception or error:

I’m trying to make my app call a number from an EditText, but I get:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=Ring Tel nr. 123456789 }

I’ve searched a while for an answer, but most of the answes are permissions and add activity to the Manifest. I’ve done both, if I’m not doing it wrong. And I’m running it on my phone, not the emulator. I’ve tried both with and without the intent-filters. Here are the codes:
Manifest: <uses-permission android:maxSdkVersion="19" android:name="android.permission.CALL_PHONE"/>

        <activity
        android:name="nu.sluggo.testapp.annons.Activity2">
        <intent-filter>
    <action android:name="android.intent.action.DIAL" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Button to make the call (gets phone number from SharedPrefs to a1 below:)

        knapp_ring.setOnClickListener(new View.OnClickListener() {
        Intent call = new Intent(Intent.ACTION_DIAL);
        @Override
        public void onClick(View v){
            call.setData(Uri.parse("Telnr:" + a1));
            startActivity(call);
        }
    });
How to solve:

Ring Tel nr. 123456789 is not a valid phone number, and that is what is in your Intent. "Telnr:" + a1 also would not appear to be valid. Use tel: followed by the phone number as the value passed to Uri.parse():

 Uri.parse("tel:" + a1)

Leave a Reply

Your email address will not be published. Required fields are marked *