Android Question EndCall routine does not work on Android 8.x !?

palmzac

Active Member
Licensed User
Longtime User
Hi,

This routine is work perfectly before Android 8.x. The MODIFY_PHONE_STATE permission already put into manifest editor. Would you help me to solve this problem ? Thanks !

B4X:
Dim r As Reflector
r.Target = r.GetContext
Dim TelephonyManager, TelephonyInterface As Object
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
TelephonyInterface = r.RunMethod("getITelephony")
r.Target = TelephonyInterface
r.RunMethod("endCall")

This is error message on Android 8.x .
 

palmzac

Active Member
Licensed User
Longtime User
Hi DonManfred,

Thank for your reply !

MODIFY_PHONE_STATE permission does not need Runtimepermissions After I check the B4A permission tool.




java.lang.SecurityException: MODIFY_PHONE_STATE permission required.

I guess you have set targetsdk to 26.
Are you using Runtimepermissions and request the right permission?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

palmzac

Active Member
Licensed User
Longtime User

I used the EndCall routine on my project. How to simulate it on Android 8.x ? Would you help me ?

my manifest


 
Upvote 0

palmzac

Active Member
Licensed User
Longtime User
Hi Erel,

Thank for you reply ! I know that.

I want to find a alternative.

I found this code on Stackoverflow. How to convert it to B4A code ? Is it possiable ?

B4X:
    TelecomManager tm = (TelecomManager)  context.getSystemService(context.TELECOM_SERVICE);

    if (tm != null) {
        boolean success = tm.endCall();
        // Call was terminated or not.
    }



It will not work. Your app will never have the MODIFY_PHONE_STATE permission.
 
Upvote 0

palmzac

Active Member
Licensed User
Longtime User
Hi Erel,

Thank for your quick reply !

Let me try.

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…