Android App to call a number on button click
Make sure you have added the <uses-permission ... />
tag at a correct level in the AndroidManifest.xml
file (outside the <application ... />
tag but within the <manifest ... />
tag):
<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>
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