diff --git a/examples/androidlcl/android/build_debug_apk.bat b/examples/androidlcl/android/build_debug_apk.bat index c59248461f..458524f93c 100644 --- a/examples/androidlcl/android/build_debug_apk.bat +++ b/examples/androidlcl/android/build_debug_apk.bat @@ -28,7 +28,7 @@ REM Resource compilation call aapt p -v -f -M AndroidManifest.xml -F bin\%APP_NAME%.ap_ -I %APK_SDK_PLATFORM%\android.jar -S res -m -J gen raw REM Java compiler -call javac -verbose -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java +call javac -verbose -encoding UTF8 -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java REM DX to convert the java bytecode to dalvik bytecode call dx --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes diff --git a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java index 846662d5ef..402dfbe085 100755 --- a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java +++ b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java @@ -312,7 +312,7 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati // ------------------------------------------- public native int LCLDrawToBitmap(int width, int height, Bitmap bitmap); public native int LCLOnTouch(float x, float y, int action); - public native int LCLOnCreate(LCLActivity lclactivity); + public native int LCLOnCreate(Activity lclactivity); public native int LCLOnMessageBoxFinished(int Result, int DialogType); public native int LCLOnKey(int kind, int keyCode, KeyEvent event, int AChar); public native int LCLOnTimer(Runnable timerid); diff --git a/examples/androidlcl/androidlcltest.lpr b/examples/androidlcl/androidlcltest.lpr index e20f9647e3..641682899e 100644 --- a/examples/androidlcl/androidlcltest.lpr +++ b/examples/androidlcl/androidlcltest.lpr @@ -31,6 +31,7 @@ begin end; begin + CDWidgetset.ActivityClassName := 'com/pascal/lcltest/LCLActivity'; CDWidgetset.ActivityOnCreate := @MyActivityOnCreate; end. diff --git a/lcl/interfaces/customdrawn/customdrawnint.pas b/lcl/interfaces/customdrawn/customdrawnint.pas index 9e01d1a1a1..7c4ab84d5b 100644 --- a/lcl/interfaces/customdrawn/customdrawnint.pas +++ b/lcl/interfaces/customdrawn/customdrawnint.pas @@ -268,6 +268,7 @@ type // Android Activity callbacks ActivityOnCreate: TProcedure; + ActivityClassName: string; constructor Create; override; destructor Destroy; override; diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc index d1b0be90be..a03b025e24 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc @@ -313,7 +313,7 @@ begin {$endif} // Very strangely in the emulator it crashes if we don't refresh the Activity class here - javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity'); + javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName)); // ad.setSingleChoiceItems( adapter, -1, MyOnClickListener); // DialogInterface.OnClickListener lclselectitemcallback; diff --git a/lcl/interfaces/customdrawn/customdrawnobject.inc b/lcl/interfaces/customdrawn/customdrawnobject.inc index 6533afd6aa..865d1724f9 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject.inc @@ -127,6 +127,8 @@ begin FTerminating := False; DefaultFontSize := 10; + ActivityClassName := 'com/pascal/lcltest/LCLActivity'; + FClipBoardFormats := TStringList.Create; FClipBoardFormats.Add('foo'); // 0 is reserved diff --git a/lcl/interfaces/customdrawn/customdrawnobject_android.inc b/lcl/interfaces/customdrawn/customdrawnobject_android.inc index 24671f96f4..f07768be2b 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_android.inc @@ -350,7 +350,7 @@ begin Result := 0; // Very strangely in the emulator it crashes if we don't refresh the Activity class here - javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity'); + javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName)); //{$ifdef VerboseCDEvents} DebugLn(Format('LCLOnMenuAction called kind=%d itemIndex=%d', [kind, itemIndex])); @@ -441,7 +441,7 @@ const NativeMethods: array[0..8] of JNINativeMethod= signature:'(FFI)I'; fnPtr:@Java_com_pascal_lclproject_LCLActivity_LCLOnTouch;), (name:'LCLOnCreate'; - signature:'(Lcom/pascal/lcltest/LCLActivity;)I'; //android/app/Activity; + signature:'(Landroid/app/Activity;)I'; // Don't use a name which includes the package name like com/pascal/lcltest/LCLActivity; fnPtr:@Java_com_pascal_lclproject_LCLActivity_LCLOnCreate;), (name:'LCLOnMessageBoxFinished'; signature:'(II)I'; @@ -484,7 +484,7 @@ begin // Find our activity class __android_log_write(ANDROID_LOG_INFO,'lclapp','Reading our Activity Class'); - javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity'); + javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName)); if not assigned(javaActivityClass) then begin __android_log_write(ANDROID_LOG_FATAL, 'lclapp', 'javaEnvRef^.FindClass failed');