4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
android.cpp File Reference

(This file was last changed: 2015-03-02 13:18:32 +0100, by Jacob Andersen)

Handles to the Java VM running our Android service. More...

#include "PAL/android.h"
#include "FSYS/log.h"
#include <cassert>
+ Include dependency graph for android.cpp:

Functions

jint JNI_OnLoad (JavaVM *vm, void *)
 JNI initialization function. More...
 
void JNI_OnUnload (JavaVM *vm, void *)
 JNI deinitialization function. More...
 

Variables

static JavaVM * theVM = nullptr
 
static jobject classLoader = nullptr
 
static jobject androidContext = nullptr
 

Detailed Description

This component bridges the C++ and Java worlds of the Android service by providing the handles into the Android/Java world needed by the C++ components of the PAL layer.

Author
Jacob Andersen, The Alexandra Institute, © 2015

Function Documentation

jint JNI_OnLoad ( JavaVM *  vm,
void *   
)

This function is called by the JNI (or the Qt library when used in a QtAndroid context) when the library has been loaded and should initialize itself.

We use it to save references to the JavaVM and the Java ClassLoader to use for loading 4S Java classes.

Parameters
vmThe JavaVM pointer.
void JNI_OnUnload ( JavaVM *  vm,
void *   
)

This function is called by the JNI (or the Qt library when used in a QtAndroid context) when the library is being unloaded.

We use it to free the references saved in the JNI_OnLoad() function.

Parameters
vmThe JavaVM pointer.