You've already forked lazarus-ccr
Improvements to the JNI Test
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2165 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="AndroidLCLTest" default="help">
|
||||
<project name="AndroidJNITest" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
|
88
bindings/android-ndk/examples/jnitest/jni/nativetest.lpi
Normal file
88
bindings/android-ndk/examples/jnitest/jni/nativetest.lpi
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="nativetest.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="nativetest"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../libs/armeabi/libnativetest.so"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<Libraries Value="/home/felipe/Programas/android-ndk-r5/platforms/android-9/arch-arm/usr/lib/;/home/felipe/Programas/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/lib/gcc/arm-eabi/4.4.0/"/>
|
||||
<OtherUnitFiles Value="../../.."/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<RelocatableUnit Value="True"/>
|
||||
<TargetCPU Value="arm"/>
|
||||
<TargetOS Value="linux"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<ExecutableType Value="Library"/>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CustomOptions Value="-Xd"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@ -1,7 +1,6 @@
|
||||
library nativetest;
|
||||
{$ifdef fpc}
|
||||
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
@ -11,7 +10,7 @@ uses
|
||||
const curClass:JClass=nil;
|
||||
nativeCodeLoaded:JfieldID=nil;
|
||||
|
||||
function Java_com_bero_nativetest_Main_stringFromJNI(env:PJNIEnv;this:jobject):jstring;{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}
|
||||
function Java_com_bero_nativetest_Main_stringFromJNI(env:PJNIEnv;this:jobject):jstring; cdecl;
|
||||
var x:single;
|
||||
begin
|
||||
__android_log_write(ANDROID_LOG_INFO,'nativetest','Java_com_bero_nativetest_Main_stringFromJNI entered');
|
||||
@ -26,17 +25,18 @@ const NativeMethods:array[0..0] of JNINativeMethod=
|
||||
signature:'()Ljava/lang/String;';
|
||||
fnPtr:@Java_com_bero_nativetest_Main_stringFromJNI;));
|
||||
|
||||
function JNI_OnLoad(vm:PJavaVM;reserved:pointer):jint;{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}
|
||||
function JNI_OnLoad(vm:PJavaVM;reserved:pointer):jint; cdecl;
|
||||
begin
|
||||
curVM:=vm;
|
||||
__android_log_write(ANDROID_LOG_INFO,'nativetest','JNI_OnLoad called');
|
||||
__android_log_write(ANDROID_LOG_INFO,'nativetest',PChar(Format('CurVM=%x', [PtrInt(CurVM)])));
|
||||
if curVM^.GetEnv(curVM,@curEnv,JNI_VERSION_1_6)<>JNI_OK then begin
|
||||
__android_log_write(ANDROID_LOG_FATAL,'nativetest','curVM^.GetEnv failed');
|
||||
result:=JNI_ERR;
|
||||
exit;
|
||||
end;
|
||||
|
||||
curClass:=curEnv^.FindClass(curEnv,'com/bero/nativetest/Main');
|
||||
curClass:=curEnv^.FindClass(curEnv,'com/pascal/jnitest/AndroidJNITest');
|
||||
if not assigned(curClass) then begin
|
||||
__android_log_write(ANDROID_LOG_FATAL,'nativetest','curEnv^.FindClass failed');
|
||||
result:=JNI_ERR;
|
||||
@ -58,7 +58,7 @@ begin
|
||||
result:=JNI_VERSION_1_6;
|
||||
end;
|
||||
|
||||
procedure JNI_OnUnload(vm:PJavaVM;reserved:pointer);{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}
|
||||
procedure JNI_OnUnload(vm:PJavaVM;reserved:pointer); cdecl;
|
||||
begin
|
||||
end;
|
||||
|
||||
|
@ -10,7 +10,6 @@ public class AndroidJNITest extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
TextView tv = new TextView(this);
|
||||
tv.setText( stringFromJNI() );
|
||||
|
Reference in New Issue
Block a user