Jump to content
Sign in to follow this  

Need Help Java to Pascal

Recommended Posts

Posted (edited)



I am trying to use Admob Rewarded Video on Delphi and found this solution https://enhance.co/documentation/native-android/rewarded-ads


They have java connector and I converted this Jar library with Java2OP.exe to pascal. (files attached post)

I can use basic java classes but I dont know how to use java procedures, I need help this level. can any one help me how can run this java example code on delphi.

Thank you.


This code working and showing rewarded video successful.

if TJEnhance.JavaClass.isRewardedAdReady=true then


This is what I need to pascal

if(Enhance.isRewardedAdReady()) {
    // The ad is ready, show it
    Enhance.showRewardedAd(new RewardCallback()
        // Callbacks:
        public void onRewardGranted(int rewardValue, RewardType rewardType)
            if(rewardType == RewardType.ITEM)
                writeLog("Reward granted (item)");

            else if(rewardType == RewardType.COINS)
                writeLog("Reward granted (coins), value: " + rewardValue);

        public void onRewardDeclined()
            writeLog("Reward declined");

        public void onRewardUnavailable()
            writeLog("Reward unavailable");


Enhance-Connector.pas about TJEnhance_RewardCallback 

  JEnhance_RewardCallbackClass = interface(IJavaClass)

  JEnhance_RewardCallback = interface(IJavaInstance)
    procedure onRewardDeclined; cdecl;
    procedure onRewardGranted(P1: Integer; P2: JEnhance_RewardType); cdecl;
    procedure onRewardUnavailable; cdecl;
  TJEnhance_RewardCallback = class(TJavaGenericImport<JEnhance_RewardCallbackClass, JEnhance_RewardCallback>) end;

  JEnhance_RewardTypeClass = interface(JEnumClass)
    {class} function _GetCOINS: JEnhance_RewardType; cdecl;
    {class} function _GetITEM: JEnhance_RewardType; cdecl;
    {class} function valueOf(P1: JString): JEnhance_RewardType; cdecl;
    {class} function values: TJavaObjectArray<JEnhance_RewardType>; cdecl;
    {class} property COINS: JEnhance_RewardType read _GetCOINS;
    {class} property ITEM: JEnhance_RewardType read _GetITEM;

  JEnhance_RewardType = interface(JEnum)
  TJEnhance_RewardType = class(TJavaGenericImport<JEnhance_RewardTypeClass, JEnhance_RewardType>) end;





Edited by pieomy

Share this post

Link to post
6 hours ago, pieomy said:

This is what I need to pascal

You cannot do that part in Delphi; it needs to be done in Java, then you can consume it from your Delphi code.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this