Issue

When trying to invoke the Phone Dialer programmatically the following exception occurs.

10-24 11:37:41.127: D/DesiZindagi(1599): AudioPlayerScreen$3:109-in : Button Advert onClick(..)
10-24 11:37:41.137: V/DesiZindagi(1599): AudioPlayerScreen$3:117-Phone : 510225454311
10-24 11:37:41.137: I/ActivityManager(99): Starting activity: Intent { act=android.intent.action.CALL dat=tel:510225454311 cmp=com.android.phone/.OutgoingCallBroadcaster }
10-24 11:37:41.137: W/ActivityManager(99): Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:5105454311 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{44c03e08 1599:com.livrona.apps.radio/10080} (pid=1599, uid=10080) requires android.permission.CALL_PHONE
10-24 11:37:41.137: E/DesiZindagi(1599): AudioPlayerScreen$3:125-Failed to invoke call
10-24 11:37:41.137: E/DesiZindagi(1599): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:5105454311 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{44c03e08 1599:com.livrona.apps.radio/10080} (pid=1599, uid=10080) requires android.permission.CALL_PHONE
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.os.Parcel.readException(Parcel.java:1247)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.os.Parcel.readException(Parcel.java:1235)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1306)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1505)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.Activity.startActivityFromChild(Activity.java:3098)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.Activity.startActivityForResult(Activity.java:2878)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.Activity.startActivity(Activity.java:2964)
10-24 11:37:41.137: E/DesiZindagi(1599):      at com.livrona.apps.radio.activity.AudioPlayerScreen$3.onClick(AudioPlayerScreen.java:123)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.view.View.performClick(View.java:2408)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.view.View$PerformClick.run(View.java:8817)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.os.Handler.handleCallback(Handler.java:587)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.os.Handler.dispatchMessage(Handler.java:92)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.os.Looper.loop(Looper.java:143)
10-24 11:37:41.137: E/DesiZindagi(1599):      at android.app.ActivityThread.main(ActivityThread.java:4914)
10-24 11:37:41.137: E/DesiZindagi(1599):      at java.lang.reflect.Method.invokeNative(Native Method)<!>

Solution

In order to be able to launch the phone dialer from the app, the CALL_PHONE permission needs to be request by the app.

Add the following permission in the AndroidManifest.xml  of your app and try again.

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