Ranja AZ 2 Posted July 24, 2021 I need to intercepte USSD response in Android. Following link https://newbedev.com/prevent-ussd-dialog-and-read-ussd-response example written by Java, I need to create the same in Delphi but I have no idea. Else, Is there anyone who has experience on using TelephonyManager.UssdResponseCallback. (https://developer.android.com/reference/android/telephony/TelephonyManager.UssdResponseCallback)? Can help? Thanks Share this post Link to post
Dave Nottage 552 Posted August 9, 2021 This looks like two questions. The first part is not currently possible using Delphi code, since there's no option to use AccessibilityService (there is for a plain Service and JobIntentService) In order to use UssdResponseCallback you need to write Java code, since you need to create a descendant of it (this is otherwise not currently possible in Delphi), and override its methods. You could define a Java interface that the descendant takes as a parameter in its constructor, and uses to redirect the overridden methods, much like I have in the code here: https://github.com/DelphiWorlds/Kastri/tree/master/Java/Base/Connectivity This Java code would need to be compiled into a jar which the Delphi app can consume. You would need to import the Java code into Delphi code. Using the same example above, this is the corresponding Delphi import: https://github.com/DelphiWorlds/Kastri/blob/master/API/DW.Androidapi.JNI.DWNetworkCallback.pas The next step is to construct a class that implements the interface defined earlier. Following the same example, that is TNetworkCallbackDelegate in this unit: https://github.com/DelphiWorlds/Kastri/blob/master/Features/Connectivity/DW.Connectivity.Android.pas You would then create an instance of the "delegate", and pass a reference to that when creating an instance of the descendant. Again following the above example, it would be similar to the code here: https://github.com/DelphiWorlds/Kastri/blob/82da3db3d0a526f6e93a30f3eb1a6c14779399bb/Features/Connectivity/DW.Connectivity.Android.pas#L98 1 Share this post Link to post
Ranja AZ 2 Posted August 11, 2021 Dave Nottage, thanks you again for your response! I'll try it! Regard Share this post Link to post