0

Android Studio

anyone can help me fix this the problem happened when call intent to place a call

the problem happened after some edits but I forget what I did I just added a new activity also after removing it the problem still

this is logcat error

2020-08-08 16:31:28.351 2191-2191/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2020-08-08 16:31:28.353 2191-2191/? E/Zygote: accessInfo : 1
2020-08-08 16:31:28.369 2191-2191/? E/3p.unitssender: Unknown bits set in runtime_flags: 0x8000
2020-08-08 16:31:29.328 2191-2191/com.th3p.unitssender2 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.th3p.unitssender2, PID: 2191
    java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxxxxxxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity (has extras) } from ProcessRecord{22be400 2191:com.th3p.unitssender2/u0a590} (pid=2191, uid=10590) with revoked permission android.permission.CALL_PHONE
        at android.os.Parcel.createException(Parcel.java:2088)
        at android.os.Parcel.readException(Parcel.java:2056)
        at android.os.Parcel.readException(Parcel.java:2004)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:4328)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1713)
        at android.app.Activity.startActivityForResult(Activity.java:5252)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
        at android.app.Activity.startActivityForResult(Activity.java:5203)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
        at android.app.Activity.startActivity(Activity.java:5581)
        at android.app.Activity.startActivity(Activity.java:5549)
        at com.th3p.unitssender2.MainActivity$3.onClick(MainActivity.java:520)
        at android.view.View.performClick(View.java:7869)
        at android.widget.TextView.performClick(TextView.java:14958)
        at android.view.View.performClickInternal(View.java:7838)
        at android.view.View.access$3600(View.java:886)
        at android.view.View$PerformClick.run(View.java:29362)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
     Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1378)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:921)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:694)
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1925)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:625)

and this is java code

        TelecomManager telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
        int simCardNumber = 0; //0 for first card and 1 for second
        Intent makeCall = new Intent(Intent.ACTION_CALL);
        if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(MainActivity.this,
                    new String[]{Manifest.permission.READ_PHONE_STATE},
                    REQ_CODE_PERMISSION_READ_PHONE_STATE);
        }
            makeCall.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", telecomManager.getCallCapablePhoneAccounts().get(simCardNumber));
            makeCall.setData(Uri.parse(Normal_Balance));
            startActivity(makeCall);
  • You might not have the `CALL_PHONE` permission. – CommonsWare Aug 08 '20 at 13:51
  • I did and the app has permission but here in the question I didn't put all java code – Aladdin Jiroun Aug 08 '20 at 13:59
  • " Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxxxxxxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity (has extras) } from ProcessRecord{22be400 2191:com.th3p.unitssender2/u0a590} (pid=2191, uid=10590) **with revoked permission android.permission.CALL_PHONE** " - Are you sure about having the permission? – Bö macht Blau Aug 08 '20 at 14:13
  • @Bö macht Blau yes pretty sure – Aladdin Jiroun Aug 08 '20 at 14:19
  • 1
    `CALL_PHONE` is a `dangerous` permission. You need to use `requestPermissions()` to request it, and not try to place phone calls until *after you have received permission* (e.g., from `onPermissionRequestResult()`). – CommonsWare Aug 08 '20 at 14:21
  • @CommonsWare also on send SMS it gives error – Aladdin Jiroun Aug 08 '20 at 16:04
  • java.lang.SecurityException: Sending SMS message: uid 10534 does not have android.permission.SEND_SMS. – Aladdin Jiroun Aug 08 '20 at 16:05
  • `SEND_SMS` also is a `dangerous` permission. As with `CALL_PHONE`, you need to use `requestPermissions()` to request it, and not try to send SMS messages until after you have received permission (e.g., from `onRequestPermissionsResult()`). BTW, I apologize for having the wrong callback name in my previous comment. – CommonsWare Aug 08 '20 at 16:15
  • @CommonsWare could you gave me an example for the best way to request permissions I use these in my app SEND_SMS READ_SMS RECEIVE_SMS CALL_PHONE READ_PHONE_STATE" – Aladdin Jiroun Aug 08 '20 at 16:56
  • the problem solved when I go manually to app info then remove the permissions and gave it again – Aladdin Jiroun Aug 08 '20 at 17:23
  • https://stackoverflow.com/questions/34342816/android-6-0-multiple-permissions I used this way to request permission and the problem fixed – Aladdin Jiroun Aug 09 '20 at 05:49
  • @CommonsWare Thank you so much for helping me to fix the problem – Aladdin Jiroun Aug 09 '20 at 05:51

1 Answers1

0

the problem was because the permission I have solved the problem by requesting permissions in a different way

I used this one here

Android 6.0 multiple permissions