0

I was trying to send USSD using the below

String ussdCode = mDataset.get(position).getCode();
                if (ussdCode != null) {
                    ussdCode = ussdCode.replace("#", Uri.encode("#"));
                    context.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));
                }

And my android-manifest i have added permissions

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

However with some device throw exception this

Fatal Exception: java.lang.SecurityException
Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxx cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{694e5b 12138:uz.mobileprovider/u0a70} (pid=12138, uid=10070) with revoked permission android.permission.CALL_PHONE
 Raw Text
android.os.Parcel.readException (Parcel.java:1683)
android.app.Activity.startActivity (Activity.java:4475)
uz.mobileprovider.MyAdapter$1.onClick (MyAdapter.java:72)
android.view.View.performClick (View.java:5609)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)

What have i wrote wrong. Please help.

user1214083
  • 122
  • 6
  • 1
    which version you run your app, if your app api level is <= 23 then you need to get dynamic permission – Farmer Oct 04 '16 at 12:46
  • it throws on android 7 – user1214083 Oct 04 '16 at 12:49
  • then you first need to get run time permission then use this code, Please check this that how to get run time permission http://stackoverflow.com/questions/39404356/i-have-to-programmatically-retrieve-permissions-group-from-the-manifest-xml-of-a/39410610#39410610 – Farmer Oct 04 '16 at 13:31

0 Answers0