Changed my code a little using CallObjectMethodA and now the LDisplayObject is created allright but the app still crashes.
Modified code:
// Get the display object
lParams[0].l := javaString_getDefaultDisplay;
lDisplayObject := javaEnvRef^^.CallObjectMethodA(javaEnvRef, lWindowManagerObject, javaMethod_getSystemService, @lParams[0]);
// lDisplayObject := javaEnvRef^^.CallObjectMethod(javaEnvRef, lWindowManagerObject, javaMethod_getDefaultDisplay);
if lDisplayObject <> nil then
debugln('******* lDisplayObject NOT nil *******')
else
debugln('******* lDisplayObject nil *******');
javaMethod_getRotation := javaEnvRef^^.GetMethodID(javaEnvRef, displayClass, 'getRotation', '()I');
if javaMethod_getRotation <> nil then
debugln('******* javaMethod_getRotation NOT nil *******')
else
debugln('******* javaMethod_getRotation nil *******');
// Now call the method from the display object
// lParams[0].j := 300;
rotation := javaEnvRef^^.CallLongMethod(javaEnvRef, lDisplayObject, javaMethod_getRotation);
debugln('rotation: ' + IntToStr(rotation));
except
on E:Exception do
debugln('Error:'+ E.Message);
end;
and crash message:
I/ActivityManager( 1157): Displayed com.pascal.JNITest/.LCLActivity: +582ms
I/lclapp ( 7838): ******* windowManagerClass NOT nil *******
I/lclapp ( 7838): ******* displayClass NOT nil *******
I/lclapp ( 7838): ******* javaString_WINDOW_SERVICE NOT nil *******
I/lclapp ( 7838): ******* lWindowManagerObject NOT nil *******
I/lclapp ( 7838): ******* javaString_getDefaultDisplay NOT nil *******
I/lclapp ( 7838): ******* javaMethod_getDefaultDisplay NOT nil *******
I/lclapp ( 7838): ******* lDisplayObject NOT nil *******
I/lclapp ( 7838): ******* javaMethod_getRotation NOT nil *******
I/lclapp ( 7838): rotation: 1073832832
D/AndroidRuntime( 7838): Shutting down VM
W/dalvikvm( 7838): threadid=1: thread exiting with uncaught exception (group=0x4001d560)