I'm trying to make a call when I press a button in android
((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String phno="10digits"; Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phno)); startActivity(i); } });
But when I run and click on the button it gives me the error
ERROR/AndroidRuntime(1021): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=9392438004 }
How can I resolve this problem?
Href=tel: creates the call link. This tells the browser how to use the number. “Tel: 123-456-7890 “creates the HTML phone number. The number within the quotes is the number it will call.
Click-to-call buttons are exactly as they sound. You provide website visitors with your phone number via a clickable link. If a prospect or customer clicks on the link, it immediately starts dialing.
Most modern devices support the tel: scheme. So use <a href="tel:555-555-5555">555-555-5555</a> and you should be good to go.
Have you given the permission in the manifest file
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
and inside your activity
Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:123456789")); startActivity(callIntent);
Let me know if you find any issue.
There are two intents to call/start calling: ACTION_CALL and ACTION_DIAL.
ACTION_DIAL
will only open the dialer with the number
filled in, but allows the user to actually call or reject the call
. ACTION_CALL
will immediately call the number and requires an extra permission.
So make sure you have the permission
uses-permission android:name="android.permission.CALL_PHONE"
in your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.dbm.pkg" android:versionCode="1" android:versionName="1.0"> <!-- NOTE! Your uses-permission must be outside the "application" tag but within the "manifest" tag. --> <uses-permission android:name="android.permission.CALL_PHONE" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <!-- Insert your other stuff here --> </application> <uses-sdk android:minSdkVersion="9" /> </manifest>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With