0

I am working with android.hardware.camera2.params.StreamConfigurationMap object in a Delphi (10.2 Tokyo) application. I need to call the getOutputSizes function. The Java2OP tool has created the interface that looks like:

function getOutputSizes(klass: Jlang_Class): TJavaObjectArray<Jutil_Size>; cdecl; overload;

In Java the call looks like map.getOutputSizes(SurfaceTexture.class); In Delphi, I have created an instance of the StreamConfigurationMap object from the CameraCharacteristics instance like this:

map := TJStreamConfigurationMap.Wrap((mCameraCharacteristics.get(TJCameraCharacteristics.JavaClass.SCALER_STREAM_CONFIGURATION_MAP) as ILocalObject).GetObjectID);

And in order to call the getOutputSizes function I am doing this:

availableSizes := map.getOutputSizes(TJlang_Class.JavaClass.forName(StringToJString('SurfaceTexture')));

is TJlang_Class.JavaClass.forName(StringToJString('SurfaceTexture')) the best translation for SurfaceTexture.class in Java?

Thank you
Sam

Sam
  • 2,473
  • 3
  • 18
  • 29
  • 1
    Almost. `forName()` requires a fully qualified name, so you would need to use `'android.graphics.SurfaceTexture'` instead. – Remy Lebeau Dec 04 '17 at 19:51
  • 1
    That being said, if you have a `TJSurfaceTexture` class using Embarcadero's JNI bridge framework, it has a public static `GetClsID()` method that returns a `Pointer` to the raw JNI class reference (specifically, it is a `jobject` returned by JNI's `NewGlobalRef()` function). I wonder if you can somehow convert that to a `Jlang_Class`? Maybe `TJlang_Class.Wrap()` will work? Look at the source code in `$(BDS)\source\rtl\android\Androidapi.JNIBridge.pas` to see how the bridge framework uses JNI class references, it might give you some ideas – Remy Lebeau Dec 04 '17 at 20:08

0 Answers0