OSCON 2012 notes
Paulo Pinto
pjmlp at progtools.org
Sun Jul 22 23:59:32 PDT 2012
>"Nick Sabalausky" wrote in message news:20120723010439.00006efc at unknown...
>I wouldn't know. I haven't actually dealt with the android SDK
>directly, only Marm. When I saw google saying you use either Java or
>straight natively-compiled C++, I guess I assumed that meant an actual
>C++ API.
No, actually you are still dealing with JNI. Google's position on native
code, is that
you should use it just for code hotspots, gamming or to port "legacy" code.
[quote]In general, you should only use the NDK if it is essential to your
app—
never because you simply prefer to program in C/C++.[/quote]
http://developer.android.com/tools/sdk/ndk/index.html
The native activity is actually a Java Activity with a specific set of
methods defined
as native methods.
http://developer.android.com/reference/android/app/NativeActivity.html
You are only allowed to access these libraries:
- libc (C library) headers
- libm (math library) headers
- JNI interface headers
- libz (Zlib compression) headers
- liblog (Android logging) header
- OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
- libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).
- A Minimal set of headers for C++ support
- OpenSL ES native audio libraries
- Android native application APIS
The Android native applications APIs are C wrappers around JNI calls,
meaning you get a performance
hit when calling them due to marshling. This is described in the
STABLE-APIS.html document delivered
as part of the NDK.
[quote]Starting from API level 9, it is possible to entirely write an
Android
application with native code (i.e. without any Java). That does not mean
that your code does not run inside a VM though, and most of the features
of the platform will still need to be accessed through JNI.[/quote]
Java is the main language to develop standard applications on Android,
everything else are just
workarounds, even if we don't like it.
Another example are the new low level Codec APIs in Jelly Bean, which are
only exposed directly via JNI to
Java.
http://developer.android.com/reference/android/media/MediaCodec.html
--
Paulo
More information about the Digitalmars-d
mailing list