Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - No activity found to handle intent action.dial

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);
        }
    });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...