Lamw Framework Fundamental
Lamw Framework Fundamental
Lamw Framework Fundamental
Authors:
José Marques Pessoa
CUA/UFMT
https://github.com/jmpessoa/lazandroidmodulewizard
http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html
Some of basic applications includes an calendar, email client, SMS program, maps,
making phone calls, accessing the Web browser, accessing your contacts list and
others.
2. Application Framework [Developers Layer - High]:
The Dalvik VM enables every Android application to run in its own process, with
its own instance of the Dalvik virtual machine.
The Dalvik executes files in executable (.Dex) optimized for minimum memory.
The source code (Java) is compiled to a class file (.class) with Java compiler which
is later transformed to Dalvik Executable by DX tools.
Core java libraries
The core java libraries help developers to write applications using standard Java
programming language.
V. Linux Kernel
The kernel also acts as an abstraction layer between hardware and the rest of the
software stack.
Others components:
.Java JDK
.Android SDK
.Android NDK
.Ant [java make]
Eclipse + ADT [Plugin] or Android Studio
A specification/protocol for calling 'native' code from Java and Java code from
native applications ('Invocation API');
An interface that allows Java to interact with code written in another language:
The Java code can invoke native methods;
An interface that allows code written in another language to interact with Java :
The native code can instantiate Java objects and invoke methods;
JNI is about "Programming for the Java Virtual Machine";
JNI is used to interact with "native" code produced by system-level language like
C, C++ and Pascal.
Motivation
Development
.Create a Java class with native method(s): --->> public native void
sayHello(String who, int times);
.compile [JDK javac] to get the ".class"
.run the JDK javah to generate C signature [.h]
.Implement the function in native library
.Load the library which implements the method: System.loadLibrary("Hello");
.write Java code that uses the library
.Invoke the native method from Java
Example
---------------------------------------------------------
"org_cuaufmt_jniexamples_Hello.h"
#include <jni.h>
JNIEXPORT void JNICALL Java_org_cuaufmt_jniexamples_Hello_sayHello(JNIEnv *,
jobject, jstring, jint);
--------------------------------------------------------
"Hello.c"
#include <stdio.h>
#include "org_cuaufmt_jniexamples_Hello.h"
JNIEXPORT void JNICALL Java_com_marakana_jniexamples_Hello_sayHi (JNIEnv *env,
jobject obj, jstring who, jint times) {
jint i;
jboolean iscopy;
const char *name;
name = (*env)->GetStringUTFChars(env, who, &iscopy);
for (i = 0; i < times; i++) {
printf("Hello %s\n", name);
}
}
Compile
libHello.so, //linux
Hello.dll, //win
libHello.jnilib //mac
Linux, FreeBSD, Haiku, Mac OS X/iOS/Darwin, DOS, Win32, Win64, WinCE, OS/2,
MorphOS,
Inline Assembler;
program HelloAsm;
var
begin
num := 10;
{$ASMMODE intel}
asm
end;
end;
Incoming News -
[Target to] Java Script [see SmartPascal ...]
GCC compiler supports linking with objects and shared objects compiled in Free
Pascal
Project Wizard
Tools [helpers]
Settings Paths: [Jdk, Sdk, Ndk, Ant, ...]
Late: Apk Build/Install
New jComponent Creator
Java::[App.java] JNI
Pascal::[controls.pas]
Activity
CustomApp
jControls jcontls; /*controls.java*/
libcontrols.so
onCreate
jcontls = New jControls(this, new RelativeLayout(this));
setContentView(jcontls.appLayout);
jcontrls.LoadSystemLibrary('libcontrols.so'); ----->>
JNI_OnLoad
jcontls.NativeEventOnCreate(jContls,jContls.Layout); ----->>
NativeEventOnCreate(jContls,jLayout)
CustomApp.Init(jContls,Layout);
jForm.jCreate(Self,Layout); <<-----
jForm.jCreate(Self, CustomApp.jLayout)
jComponent1.jCreate(Self,Layout); <<-----
jComponent1.jCreate(Self, CustomApp.jLayout);
... ...
... ...
jComponentN.jCreate(Self,Layout); <<----
jComponentN.jCreate(Self, CustomApp.jLayout);
... ...
... ...
Events
jComponentX.onClick();
jComponentX.NativeEventOnClick(Self); ---->>
NativeEventOnClick(Self);
XII - Screenshots
XIV - Demo
XV - References
https://github.com/jmpessoa/lazandroidmodulewizard
http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html
http://www.codeproject.com/Articles/798780/Introduction-to-Android
https://www.tbray.org/ongoing/When/201x/2010/11/14/What-Android-Is
http://blog.ameykelkar.com/2014/01/android-architecture-brief-introduction.html
http://expressmagazine.net/development/620/android-architecture
https://thenewcircle.com/static/bookshelf/java_fundamentals_tutorial/_java_native_interface_jni.html
http://homepage.cs.uiowa.edu/~slonnegr/wpj/JNI.pdf
http://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html
http://justobjects.org/cowcatcher/browse/advjava/slides/java-jni/core/jni/slide.0.20.html
https://blog.udemy.com/pascal-ide/
http://expressmagazine.net/development/620/android-architecture#sthash.UPW1J03x.dpuf
http://www.cubrid.org/blog/dev-platform/android-at-a-glance/
http://gkonandroid.blogspot.com.br/2013/11/mvc-architecture-in-android.html
ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf
http://www.math.uni-leipzig.de/pool/tuts/FreePascal/prog/node13.html