Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
android_utils.h File Reference

Functions for Android. More...

#include <geogram/basic/common.h>
#include <geogram/basic/numeric.h>
#include <geogram/basic/argused.h>
#include <android/log.h>
#include <string>

Go to the source code of this file.

Namespaces

 GEO
 Global Vorpaline namespace.
 

Functions

void GEO::AndroidUtils::show_soft_keyboard (android_app *app)
 Shows the software keyboard on the phone. More...
 
void GEO::AndroidUtils::hide_soft_keyboard (android_app *app)
 Hides the software keyboard on the phone. More...
 
Numeric::int32 GEO::AndroidUtils::keycode_to_unicode (android_app *app, Numeric::int32 deviceId, Numeric::int32 keyCode, Numeric::int32 metaState)
 Converts a keycode to a Unicode character. More...
 
bool GEO::AndroidUtils::has_permission (android_app *app, const char *perm)
 Tests whether a permission is granted. More...
 
void GEO::AndroidUtils::request_permissions (android_app *app, int nb_perms, const char **perms)
 Request permissions. More...
 
std::string GEO::AndroidUtils::temp_folder (android_app *app)
 Gets the path for temporary file. More...
 
void GEO::AndroidUtils::debug_log (const char *str)
 Displays a message in the android log in Debug mode, ignored in Release mode. More...
 
void GEO::AndroidUtils::debug_log (const std::string &str)
 Displays a message in the android log in Debug mode, ignored in Release mode. More...
 
void GEO::AndroidUtils::debug_show_event (AInputEvent *event)
 Displays an android event in the android log in Debug mode, ignored in release mode. More...
 

Detailed Description

Functions for Android.

Definition in file android_utils.h.

Function Documentation

◆ debug_log() [1/2]

void GEO::AndroidUtils::debug_log ( const char *  str)
inline

Displays a message in the android log in Debug mode, ignored in Release mode.

The message can be displayed using 'adb logcat | grep GEOGRAM'

Parameters
[in]strthe message to be displayed

Definition at line 125 of file android_utils.h.

◆ debug_log() [2/2]

void GEO::AndroidUtils::debug_log ( const std::string &  str)
inline

Displays a message in the android log in Debug mode, ignored in Release mode.

The message can be displayed using 'adb logcat | grep GEOGRAM'

Parameters
[in]strthe message to be displayed

Definition at line 141 of file android_utils.h.

◆ debug_show_event()

void GEO::AndroidUtils::debug_show_event ( AInputEvent *  event)

Displays an android event in the android log in Debug mode, ignored in release mode.

The message can be displayed using 'adb logcat | grep GEOGRAM'

Parameters
[in]eventthe event to be displayed

◆ has_permission()

bool GEO::AndroidUtils::has_permission ( android_app *  app,
const char *  perm 
)

Tests whether a permission is granted.

Parameters
[in]appa pointer to the android app.
[in]permthe name of the permission, e.g., "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE".
Return values
trueif the permission is granted.
falseotherwise.
Note
Requires Android API level 23 (Marshmallow, May 2015)

◆ hide_soft_keyboard()

void GEO::AndroidUtils::hide_soft_keyboard ( android_app *  app)

Hides the software keyboard on the phone.

Parameters
[in]appa pointer to the android app.

◆ keycode_to_unicode()

Numeric::int32 GEO::AndroidUtils::keycode_to_unicode ( android_app *  app,
Numeric::int32  deviceId,
Numeric::int32  keyCode,
Numeric::int32  metaState 
)

Converts a keycode to a Unicode character.

Parameters
[in]appa pointer to the android app.
[in]deviceId,keyCode,metaStateobtained from the InputEvent.

◆ request_permissions()

void GEO::AndroidUtils::request_permissions ( android_app *  app,
int  nb_perms,
const char **  perms 
)

Request permissions.

This opens the system dialog that lets the user grant (or deny) the permission.

Parameters
[in]appa pointer to the android app.
[in]nb_permsnumber of requested permissions.
[in]permsthe names of the permission, e.g., "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE".
Note
Requires Android API level 23 (Marshmallow, May 2015)

◆ show_soft_keyboard()

void GEO::AndroidUtils::show_soft_keyboard ( android_app *  app)

Shows the software keyboard on the phone.

Parameters
[in]appa pointer to the android app.

◆ temp_folder()

std::string GEO::AndroidUtils::temp_folder ( android_app *  app)

Gets the path for temporary file.

Parameters
[in]appa pointer to the android app.
Returns
a std::string with the path where to write temporary files.