Android – Making phone call – ACTION_CALL Intent

By -



try {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+98765"));
startActivity(intent);
} catch (Exception e) {
Log.e("Demo application", "Failed to invoke call", e);
}

Don’t forget to add this permission into the AndroidManifest.xml file:

<uses-permission android:name="android.permission.CALL_PHONE"/>

Note: If you forget to add this permission inside the AndroidManifest.xml file then below Exception may be raised, and from exception we can easily get solution, if you notice the exception then i am sure you will also get the point at “requires android.permission.CALL_PHONE” line in the exception.

W/ActivityManager( 2274): Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:+98765 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{462bbfc8 4603:com.paresh.demoexample/10091} (pid=4603, uid=10091) requires android.permission.CALL_PHONE
E/Demo application( 4603): Failed to invoke call
E/Demo application( 4603): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:+98765 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{462bbfc8 4603:com.paresh.demoexample/10091} (pid=4603, uid=10091) requires android.permission.CALL_PHONE
E/Demo application( 4603): 	at android.os.Parcel.readException(Parcel.java:1260)
E/Demo application( 4603): 	at android.os.Parcel.readException(Parcel.java:1248)
E/Demo application( 4603): 	at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
E/Demo application( 4603): 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
E/Demo application( 4603): 	at android.app.Activity.startActivityForResult(Activity.java:2817)
E/Demo application( 4603): 	at android.app.Activity.startActivity(Activity.java:2923)
E/Demo application( 4603): 	at com.paresh.demoexample.DemoExampleActivity.onCreate(DemoExampleActivity.java:19)
E/Demo application( 4603): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/Demo application( 4603): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/Demo application( 4603): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/Demo application( 4603): 	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/Demo application( 4603): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/Demo application( 4603): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/Demo application( 4603): 	at android.os.Looper.loop(Looper.java:123)
E/Demo application( 4603): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
E/Demo application( 4603): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/Demo application( 4603): 	at java.lang.reflect.Method.invoke(Method.java:521)
E/Demo application( 4603): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/Demo application( 4603): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/Demo application( 4603): 	at dalvik.system.NativeStart.main(Native Method)

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

Loading Facebook Comments ...
Loading Disqus Comments ...