DDraceNetwork Docs
Android

Functions

const char * InitAndroid ()
 
void RestartAndroidApp ()
 
bool StartAndroidServer ()
 
void ExecuteAndroidServerCommand (const char *pCommand)
 
bool IsAndroidServerRunning ()
 

Detailed Description

Android-specific functions to interact with the ClientActivity.

Important note: These functions may only be called from the main native thread which is created by the SDLActivity (super class of ClientActivity), otherwise JNI calls are not possible because the JNI environment is not attached to that thread. See https://developer.android.com/training/articles/perf-jni#threads

Function Documentation

◆ ExecuteAndroidServerCommand()

void ExecuteAndroidServerCommand ( const char *  pCommand)

Adds a command to the execution queue of the local server.

Parameters
pCommandThe command to enqueue.

◆ InitAndroid()

const char * InitAndroid ( )

Initializes the Android storage. Must be called on Android-systems before using any of the I/O and storage functions.

This will change the current working directory to the app specific external storage location and unpack the assets from the APK file to the data folder. The folder user is created in the external storage to store the user data.

Failure must be handled by exiting the app.

Returns
nullptr on success, error message on failure.

◆ IsAndroidServerRunning()

bool IsAndroidServerRunning ( )

Returns whether the local server and its Android service are running.

Returns
true if the server is running, false if the server is stopped.

◆ RestartAndroidApp()

void RestartAndroidApp ( )

Sends an intent to the Android system to restart the app.

This will restart the main activity in a new task. The current process must immediately terminate after this function is called.

◆ StartAndroidServer()

bool StartAndroidServer ( )

Starts the local server as an Android service.

This will request the notification-permission as it is required for foreground services to show a notification.

Returns
true on success, false on error.