Search code examples
androiddelphifiremonkey

Is there any way with FireMonkey to use android-support-v4 that goes with Marshmallow?


I need the android-support-v4 that goes with Android Marshmallow because it's contain the object PermissionChecker and it's the only way to know (on Marshmallow and up) if a user has denied an app permission (like location for example).

I saw C:\Program Files (x86)\Embarcadero\Studio\18.0\lib\android\debug\android-support-v4.jar but I don't see any PermissionChecker inside C:\Program Files (x86)\Embarcadero\Studio\18.0\lib\android\debug\classes.dex so i guess it's an old support-v4 that it's used inside the classes.dex.

Is there any way to update the classes.dex to use instead the latest android-support-v4 ?


Solution

  • Here's what I did:

    Used Java2OP against the android-support-v4.jar file in C:\Users\Public\Documents\Embarcadero\Studio\18.0\PlatformSDKs\android-sdk-windows\extras\android\support\v4 (you may need to download the Android Support Library in the Extras section of Android SDK Manager) because the PermissionChecker exists in that jar.

    Disabled android-support-v4.dex.jar in the Libraries node for the project.

    Added the android-support-v4.jar (mentioned in step 1) to the project

    Using TJPermissionChecker.JavaClass.checkSelfPermission now returns the correct result if the user has denied the permission (i.e. in Android 6 or above)