Ocean
Loading...
Searching...
No Matches
Ocean::Platform::Android::Utilities Class Reference

This class implements helper functions for android platforms. More...

#include <Utilities.h>

Static Public Member Functions

static bool clearPotentialException (JNIEnv &jniEnvironment)
 Checks whether a Java exception is pending on the calling thread, and clears it.
 
static ScopedJClass findClass (JNIEnv &jniEnvironment, const std::string &className)
 Returns the class with a given name, and handles a potential exception.
 
static jmethodID getMethodId (JNIEnv &jniEnvironment, jclass javaClass, const std::string &name, const std::string &signature)
 Returns the id of a non-static method of a class, and handles a potential exception.
 
static jmethodID getStaticMethodId (JNIEnv &jniEnvironment, jclass javaClass, const std::string &name, const std::string &signature)
 Returns the id of a static method of a class, and handles a potential exception.
 
static jfieldID getFieldId (JNIEnv &jniEnvironment, jclass javaClass, const std::string &name, const std::string &signature)
 Returns the id of a non-static field of a class, and handles a potential exception.
 
static jfieldID getStaticFieldId (JNIEnv &jniEnvironment, jclass javaClass, const std::string &name, const std::string &signature)
 Returns the id of a static field of a class, and handles a potential exception.
 
template<typename T = jobject, typename... TArgs>
static ScopedJNILocalObject< T > callObjectMethod (JNIEnv &jniEnvironment, jobject object, jmethodID methodId, TArgs &&... args)
 Calls a non-static Java method returning an object, and handles a potential exception.
 
template<typename T = jobject, typename... TArgs>
static ScopedJNILocalObject< T > callStaticObjectMethod (JNIEnv &jniEnvironment, jclass javaClass, jmethodID methodId, TArgs &&... args)
 Calls a static Java method returning an object, and handles a potential exception.
 
template<typename T = jobject, typename... TArgs>
static ScopedJNILocalObject< T > newObject (JNIEnv &jniEnvironment, jclass javaClass, jmethodID methodId, TArgs &&... args)
 Creates a new instance of a class, and handles a potential exception.
 
template<typename... TArgs>
static bool callVoidMethod (JNIEnv &jniEnvironment, jobject object, jmethodID methodId, TArgs &&... args)
 Calls a non-static Java method without return value, and handles a potential exception.
 
template<typename... TArgs>
static bool callBooleanMethod (JNIEnv &jniEnvironment, jobject object, jmethodID methodId, bool &returnValue, TArgs &&... args)
 Calls a non-static Java method returning a boolean, and handles a potential exception.
 
template<typename... TArgs>
static bool callStaticBooleanMethod (JNIEnv &jniEnvironment, jclass javaClass, jmethodID methodId, bool &returnValue, TArgs &&... args)
 Calls a static Java method returning a boolean, and handles a potential exception.
 
template<typename... TArgs>
static bool callIntMethod (JNIEnv &jniEnvironment, jobject object, jmethodID methodId, int32_t &returnValue, TArgs &&... args)
 Calls a non-static Java method returning an integer, and handles a potential exception.
 
template<typename... TArgs>
static bool callStaticIntMethod (JNIEnv &jniEnvironment, jclass javaClass, jmethodID methodId, int32_t &returnValue, TArgs &&... args)
 Calls a static Java method returning an integer, and handles a potential exception.
 
template<typename... TArgs>
static bool callFloatMethod (JNIEnv &jniEnvironment, jobject object, jmethodID methodId, float &returnValue, TArgs &&... args)
 Calls a non-static Java method returning a float, and handles a potential exception.
 
static std::string toAString (JNIEnv *env, jstring javaString)
 Converts a Java native string to a std string.
 
static jstring toJavaString (JNIEnv *env, const std::string &stdString)
 Converts a std string to a Java native string.
 
static jobjectArray toJavaStringArray (JNIEnv *env, const Strings &strings)
 Converts a vector of std strings to a Java array with native strings.
 
static bool toVector (JNIEnv *env, jobject javaStringList, Strings &strings)
 Converts a Java native list with string to a vector of strings.
 
static bool toVector (JNIEnv *env, jobject javaIntegerList, std::vector< int > &values)
 Converts a Java native list with integer to a vector of integers.
 
static bool className (JNIEnv *env, jobject object, std::string &name)
 Returns the class name of an object.
 
static bool manifestVersion (JavaVM *javaVM, jobject activity, int &versionCode, std::string &versionName)
 Returns the version code stored in the application manifest.
 
static bool manifestVersionCode (JavaVM *javaVM, jobject activity, int &versionCode)
 Deprecated.
 
static bool manifestSdkVersions (JNIEnv *env, jobject activity, unsigned int &minSdkVersion, unsigned int &targetSdkVersion)
 Returns the minimum and target SDK versions stored in the application manifest.
 
static bool androidReleaseVersion (JNIEnv *env, std::string &version)
 Return the Android release version of the system (android.os.Build.VERSION.RELEASE).
 
static bool androidSdkVersion (JNIEnv *env, unsigned int &version)
 Return the Android SDK version of the system (android.os.Build.VERSION.SDK).
 
static bool systemPropertyValue (const std::string &name, std::string &value)
 Returns the value of a specific system property.
 
static bool deviceBrand (JNIEnv *env, std::string &brand)
 Returns the brand string of the device.
 
static bool deviceModel (JNIEnv *env, std::string &model)
 Returns the model string of the device.
 
static bool deviceSerialNumber (std::string &serialNumber)
 Returns the serial number of the device.
 
static bool determinePackageName (std::string &packageName)
 Returns the name of the package.
 
static bool sendIntentToComponent (JNIEnv *env, jobject activity, const std::string &packageName, const std::string &className, const std::string &extraText)
 Sends an explicit intent to another component or application.
 
static bool startActivity (JNIEnv *env, jobject rootActivity, const std::string &activityClassName)
 Starts an new activity from a root activity.
 
static bool connectToWifi (JNIEnv *env, jobject activity, const std::string &ssid, const std::string &password)
 Joins a Wi-Fi network (WPA2-PSK).
 
static bool sendIntentToConnectToWifi (JNIEnv *env, jobject activity, const std::string &ssid, const std::string &password)
 Sends an intent to the OS to request it to join a Wi-Fi network (WPA2-PSK).
 
static bool currentWifiSsid (JNIEnv *env, jobject activity, std::string &ssid)
 Returns current Wi-Fi network name (SSID).
 
static bool triggerVibration (JNIEnv *env, jobject activity, unsigned int intensity=1u, const unsigned int duration=50u)
 Triggers a vibration.
 
static bool displayRefreshRate (JNIEnv *env, jobject activity, float &refreshRateHz)
 Returns the refresh rate of the display in Hz.
 

Static Protected Member Functions

template<typename... TArgs>
static constexpr bool isValidArgumentTypes ()
 Returns whether all given data types can be handed to a JNI function call with variable arguments.
 

Detailed Description

This class implements helper functions for android platforms.

Member Function Documentation

◆ androidReleaseVersion()

static bool Ocean::Platform::Android::Utilities::androidReleaseVersion ( JNIEnv *  env,
std::string &  version 
)
static

Return the Android release version of the system (android.os.Build.VERSION.RELEASE).

Parameters
envThe Java environment, must be valid
versionThe resulting Android release version, only valid if this function returns 'true'
Returns
True, if succeeded, otherwise false

◆ androidSdkVersion()

static bool Ocean::Platform::Android::Utilities::androidSdkVersion ( JNIEnv *  env,
unsigned int &  version 
)
static

Return the Android SDK version of the system (android.os.Build.VERSION.SDK).

Parameters
envThe Java environment, must be valid
versionThe resulting Android SDK version, only valid if this function returns 'true'
Returns
True, if succeeded, otherwise false

◆ callBooleanMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callBooleanMethod ( JNIEnv &  jniEnvironment,
jobject  object,
jmethodID  methodId,
bool &  returnValue,
TArgs &&...  args 
)
static

Calls a non-static Java method returning a boolean, and handles a potential exception.

The return value is provided as a parameter, as a thrown exception and a returned 'false' cannot be distinguished otherwise.

Parameters
jniEnvironmentThe JNI environment of the calling thread
objectThe object on which the method will be called, must be valid
methodIdThe id of the method to be called, must be valid
returnValueThe resulting return value of the method, only valid if this function succeeds
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ callFloatMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callFloatMethod ( JNIEnv &  jniEnvironment,
jobject  object,
jmethodID  methodId,
float &  returnValue,
TArgs &&...  args 
)
static

Calls a non-static Java method returning a float, and handles a potential exception.

The return value is provided as a parameter, as a thrown exception and a returned '0' cannot be distinguished otherwise.

Parameters
jniEnvironmentThe JNI environment of the calling thread
objectThe object on which the method will be called, must be valid
methodIdThe id of the method to be called, must be valid
returnValueThe resulting return value of the method, only valid if this function succeeds
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ callIntMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callIntMethod ( JNIEnv &  jniEnvironment,
jobject  object,
jmethodID  methodId,
int32_t &  returnValue,
TArgs &&...  args 
)
static

Calls a non-static Java method returning an integer, and handles a potential exception.

The return value is provided as a parameter, as a thrown exception and a returned '0' cannot be distinguished otherwise.

Parameters
jniEnvironmentThe JNI environment of the calling thread
objectThe object on which the method will be called, must be valid
methodIdThe id of the method to be called, must be valid
returnValueThe resulting return value of the method, only valid if this function succeeds
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ callObjectMethod()

template<typename T , typename... TArgs>
ScopedJNILocalObject< T > Ocean::Platform::Android::Utilities::callObjectMethod ( JNIEnv &  jniEnvironment,
jobject  object,
jmethodID  methodId,
TArgs &&...  args 
)
static

Calls a non-static Java method returning an object, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
objectThe object on which the method will be called, must be valid
methodIdThe id of the method to be called, must be valid
argsThe arguments of the method, must match the signature of the method
Returns
The resulting object, invalid if the method has thrown an exception or has returned null
Template Parameters
TThe data type of the returned reference, e.g., jobject or jstring
TArgsThe data types of the arguments of the method

◆ callStaticBooleanMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callStaticBooleanMethod ( JNIEnv &  jniEnvironment,
jclass  javaClass,
jmethodID  methodId,
bool &  returnValue,
TArgs &&...  args 
)
static

Calls a static Java method returning a boolean, and handles a potential exception.

The return value is provided as a parameter, as a thrown exception and a returned 'false' cannot be distinguished otherwise.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the method, must be valid
methodIdThe id of the method to be called, must be valid
returnValueThe resulting return value of the method, only valid if this function succeeds
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ callStaticIntMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callStaticIntMethod ( JNIEnv &  jniEnvironment,
jclass  javaClass,
jmethodID  methodId,
int32_t &  returnValue,
TArgs &&...  args 
)
static

Calls a static Java method returning an integer, and handles a potential exception.

The return value is provided as a parameter, as a thrown exception and a returned '0' cannot be distinguished otherwise.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the method, must be valid
methodIdThe id of the method to be called, must be valid
returnValueThe resulting return value of the method, only valid if this function succeeds
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ callStaticObjectMethod()

template<typename T , typename... TArgs>
ScopedJNILocalObject< T > Ocean::Platform::Android::Utilities::callStaticObjectMethod ( JNIEnv &  jniEnvironment,
jclass  javaClass,
jmethodID  methodId,
TArgs &&...  args 
)
static

Calls a static Java method returning an object, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the method, must be valid
methodIdThe id of the method to be called, must be valid
argsThe arguments of the method, must match the signature of the method
Returns
The resulting object, invalid if the method has thrown an exception or has returned null
Template Parameters
TThe data type of the returned reference, e.g., jobject or jstring
TArgsThe data types of the arguments of the method

◆ callVoidMethod()

template<typename... TArgs>
bool Ocean::Platform::Android::Utilities::callVoidMethod ( JNIEnv &  jniEnvironment,
jobject  object,
jmethodID  methodId,
TArgs &&...  args 
)
static

Calls a non-static Java method without return value, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
objectThe object on which the method will be called, must be valid
methodIdThe id of the method to be called, must be valid
argsThe arguments of the method, must match the signature of the method
Returns
True, if the method did not throw an exception
Template Parameters
TArgsThe data types of the arguments of the method

◆ className()

static bool Ocean::Platform::Android::Utilities::className ( JNIEnv *  env,
jobject  object,
std::string &  name 
)
static

Returns the class name of an object.

Parameters
envThe Java environment, must be valid
objectThe object for which the class name will be returned, must be valid
nameThe resulting class name
Returns
True, if succeeded

◆ clearPotentialException()

static bool Ocean::Platform::Android::Utilities::clearPotentialException ( JNIEnv &  jniEnvironment)
static

Checks whether a Java exception is pending on the calling thread, and clears it.

A pending exception makes almost every following JNI call undefined, and it terminates the process in case the thread detaches while the exception is still pending. An exception must therefore be cleared before the calling thread makes any further JNI call, returns to Java, or ends. The description of the exception is written to the error log, as Ocean cannot handle a Java exception in any other way. This function is safe to call at any time, also when no exception is pending.

Parameters
jniEnvironmentThe JNI environment of the calling thread
Returns
True, if an exception was pending and has been cleared; False, if no exception was pending

◆ connectToWifi()

static bool Ocean::Platform::Android::Utilities::connectToWifi ( JNIEnv *  env,
jobject  activity,
const std::string &  ssid,
const std::string &  password 
)
static

Joins a Wi-Fi network (WPA2-PSK).

This only works with Android SDK version 28 or below.

Parameters
envThe Java environment, must be valid
activityThe root activity from which the new activity will be started, must be valid
ssidThe Wi-Fi network name (SSID), the network must be using WPA2, must be valid
passwordThe Wi-Fi network password, must be valid
Returns
True, if joined successfully, otherwise false

◆ currentWifiSsid()

static bool Ocean::Platform::Android::Utilities::currentWifiSsid ( JNIEnv *  env,
jobject  activity,
std::string &  ssid 
)
static

Returns current Wi-Fi network name (SSID).

Parameters
envThe Java environment, must be valid
activityThe root activity from which the new activity will be started, must be valid
ssidThe resulting Wi-Fi network name (SSID), will be empty if there is no Wi-Fi connection
Returns
True, if succeeded

◆ determinePackageName()

static bool Ocean::Platform::Android::Utilities::determinePackageName ( std::string &  packageName)
static

Returns the name of the package.

Parameters
packageNameThe resulting package name
Returns
True, if succeeded

◆ deviceBrand()

static bool Ocean::Platform::Android::Utilities::deviceBrand ( JNIEnv *  env,
std::string &  brand 
)
static

Returns the brand string of the device.

Parameters
envThe Java environment, must be valid
brandThe resulting model string
Returns
True, if succeeded

◆ deviceModel()

static bool Ocean::Platform::Android::Utilities::deviceModel ( JNIEnv *  env,
std::string &  model 
)
static

Returns the model string of the device.

Parameters
envThe Java environment, must be valid
modelThe resulting model string
Returns
True, if succeeded

◆ deviceSerialNumber()

static bool Ocean::Platform::Android::Utilities::deviceSerialNumber ( std::string &  serialNumber)
static

Returns the serial number of the device.

On Android 8.0 (API 26) and above, access to the serial number is restricted to system apps.

Parameters
serialNumberThe resulting device's serial number
Returns
True, if succeeded

◆ displayRefreshRate()

static bool Ocean::Platform::Android::Utilities::displayRefreshRate ( JNIEnv *  env,
jobject  activity,
float &  refreshRateHz 
)
static

Returns the refresh rate of the display in Hz.

On Android 30 (API 30) and above, uses Activity.getDisplay(). On older versions, uses WindowManager.getDefaultDisplay().

Parameters
envThe Java environment, must be valid
activityThe Android main activity, must be valid
refreshRateHzThe resulting refresh rate in Hz, will be 0 if the display could not be determined
Returns
True, if succeeded

◆ findClass()

static ScopedJClass Ocean::Platform::Android::Utilities::findClass ( JNIEnv &  jniEnvironment,
const std::string &  className 
)
static

Returns the class with a given name, and handles a potential exception.

Beware: A thread which has been attached by Ocean has no Java frames on the stack, so that the class is resolved with the bootstrap class loader and an application class cannot be found. Resolve application classes on a thread which has been called from Java, and keep them as a global reference.

Parameters
jniEnvironmentThe JNI environment of the calling thread
classNameThe name of the class to be returned, e.g., "android/content/Intent", must be valid
Returns
The requested class, invalid if the class could not be found

◆ getFieldId()

static jfieldID Ocean::Platform::Android::Utilities::getFieldId ( JNIEnv &  jniEnvironment,
jclass  javaClass,
const std::string &  name,
const std::string &  signature 
)
static

Returns the id of a non-static field of a class, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the field, must be valid
nameThe name of the field, must be valid
signatureThe signature of the field, e.g., "Ljava/lang/String;", must be valid
Returns
The id of the field, nullptr if the field does not exist

◆ getMethodId()

static jmethodID Ocean::Platform::Android::Utilities::getMethodId ( JNIEnv &  jniEnvironment,
jclass  javaClass,
const std::string &  name,
const std::string &  signature 
)
static

Returns the id of a non-static method of a class, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the method, must be valid
nameThe name of the method, must be valid
signatureThe signature of the method, e.g., "(Ljava/lang/String;)I", must be valid
Returns
The id of the method, nullptr if the method does not exist

◆ getStaticFieldId()

static jfieldID Ocean::Platform::Android::Utilities::getStaticFieldId ( JNIEnv &  jniEnvironment,
jclass  javaClass,
const std::string &  name,
const std::string &  signature 
)
static

Returns the id of a static field of a class, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the field, must be valid
nameThe name of the field, must be valid
signatureThe signature of the field, e.g., "Ljava/lang/String;", must be valid
Returns
The id of the field, nullptr if the field does not exist

◆ getStaticMethodId()

static jmethodID Ocean::Platform::Android::Utilities::getStaticMethodId ( JNIEnv &  jniEnvironment,
jclass  javaClass,
const std::string &  name,
const std::string &  signature 
)
static

Returns the id of a static method of a class, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class providing the method, must be valid
nameThe name of the method, must be valid
signatureThe signature of the method, e.g., "(Ljava/lang/String;)I", must be valid
Returns
The id of the method, nullptr if the method does not exist

◆ isValidArgumentTypes()

template<typename... TArgs>
constexpr bool Ocean::Platform::Android::Utilities::isValidArgumentTypes ( )
staticconstexprprotected

Returns whether all given data types can be handed to a JNI function call with variable arguments.

A JNI argument is either a reference like jobject or jstring, or a primitive like jint or jboolean, as any other type would be pushed onto the variable argument list of the runtime. Beware: This does not verify that the arguments match the signature of the Java method, e.g., an jint handed to a method expecting a jlong is still wrong.

Returns
True, if so
Template Parameters
TArgsThe data types to be checked, can be empty

◆ manifestSdkVersions()

static bool Ocean::Platform::Android::Utilities::manifestSdkVersions ( JNIEnv *  env,
jobject  activity,
unsigned int &  minSdkVersion,
unsigned int &  targetSdkVersion 
)
static

Returns the minimum and target SDK versions stored in the application manifest.

Parameters
envThe Java environment, must be valid
activityThe Android main activity, must be valid
minSdkVersionThe resulting minimum SDK version of the application as defined in its manifest
targetSdkVersionThe resulting target SDK version of the application as defined in its manifest
Returns
True, if succeeded

◆ manifestVersion()

static bool Ocean::Platform::Android::Utilities::manifestVersion ( JavaVM *  javaVM,
jobject  activity,
int &  versionCode,
std::string &  versionName 
)
static

Returns the version code stored in the application manifest.

Parameters
javaVMThe Java virtual machine, must be valid
activityThe Android main activity, must be valid
versionCodeThe resulting version code of the application
versionNameThe resulting version name of the application
Returns
True, if succeeded

◆ manifestVersionCode()

static bool Ocean::Platform::Android::Utilities::manifestVersionCode ( JavaVM *  javaVM,
jobject  activity,
int &  versionCode 
)
static

Deprecated.

Returns the version code stored in the application manifest.

Parameters
javaVMThe Java virtual machine, must be valid
activityThe Android main activity, must be valid
versionCodeThe version code of the application
Returns
True, if succeeded

◆ newObject()

template<typename T , typename... TArgs>
ScopedJNILocalObject< T > Ocean::Platform::Android::Utilities::newObject ( JNIEnv &  jniEnvironment,
jclass  javaClass,
jmethodID  methodId,
TArgs &&...  args 
)
static

Creates a new instance of a class, and handles a potential exception.

Parameters
jniEnvironmentThe JNI environment of the calling thread
javaClassThe class to be instantiated, must be valid
methodIdThe id of the constructor to be called, must be valid
argsThe arguments of the constructor, must match the signature of the constructor
Returns
The resulting object, invalid if the constructor has thrown an exception
Template Parameters
TThe data type of the returned reference, e.g., jobject or jstring
TArgsThe data types of the arguments of the constructor

◆ sendIntentToComponent()

static bool Ocean::Platform::Android::Utilities::sendIntentToComponent ( JNIEnv *  env,
jobject  activity,
const std::string &  packageName,
const std::string &  className,
const std::string &  extraText 
)
static

Sends an explicit intent to another component or application.

Parameters
envThe Java environment, must be valid
activityThe Android main activity, must be valid
packageNameThe name of the package to which the intent will be sent, must be valid
classNameThe name of the class or activity to which the intent will be sent, must be valid
extraTextThe data that will be sent with the intent, must be valid
Returns
True, if the intent was sent successfully, otherwise false

◆ sendIntentToConnectToWifi()

static bool Ocean::Platform::Android::Utilities::sendIntentToConnectToWifi ( JNIEnv *  env,
jobject  activity,
const std::string &  ssid,
const std::string &  password 
)
static

Sends an intent to the OS to request it to join a Wi-Fi network (WPA2-PSK).

The intent is send to the system settings app to save and connect to a new Wi-Fi network. This will display a notification to user to accept or reject the new Wi-Fi network. Additional notes:

  • The Wi-Fi network must use the security protocol WPA2-PSK.
  • This function requires Android SDK version 29 or higher.
  • This function requires the permissions android.permission.CHANGE_NETWORK_STATE and android.permission.WRITE_SETTINGS to be set in the app manifest to work.
  • Rejecting a new network does NOT revoke the permission android.permission.CHANGE_NETWORK_STATE again. Re-tries are possible.
  • The newly added networks do NOT have to reachable at the time of adding them (they will be stored for when they become available).
  • The system app receiving the intent sent here must implement a handler for the action type Settings.ACTION_WIFI_ADD_NETWORKS. Otherwise this function will have no effect (and still return true).
    Parameters
    envThe Java environment, must be valid
    activityThe root activity from which the new activity will be started, must be valid
    ssidThe Wi-Fi network name (SSID), the network must be using WPA2, must be valid
    passwordThe Wi-Fi network password, must be valid
    Returns
    True, if the intent was sent successfully, otherwise false

◆ startActivity()

static bool Ocean::Platform::Android::Utilities::startActivity ( JNIEnv *  env,
jobject  rootActivity,
const std::string &  activityClassName 
)
static

Starts an new activity from a root activity.

Parameters
envThe Java environment, must be valid
rootActivityThe root activity from which the new activity will be started, must be valid
activityClassNameThe name of the class of the activity to start, must be valid
Returns
True, if succeeded

◆ systemPropertyValue()

static bool Ocean::Platform::Android::Utilities::systemPropertyValue ( const std::string &  name,
std::string &  value 
)
static

Returns the value of a specific system property.

Parameters
nameThe name of the system property, must be valid
valueThe resulting value
Returns
True, if succeeded

◆ toAString()

static std::string Ocean::Platform::Android::Utilities::toAString ( JNIEnv *  env,
jstring  javaString 
)
static

Converts a Java native string to a std string.

Parameters
envThe Java environment, must be valid
javaStringJava string to be converted, may be nullptr
Returns
Resulting std string

◆ toJavaString()

static jstring Ocean::Platform::Android::Utilities::toJavaString ( JNIEnv *  env,
const std::string &  stdString 
)
static

Converts a std string to a Java native string.

Parameters
envThe Java environment, must be valid
stdStringStd string to be converted
Returns
Resulting Java native string

◆ toJavaStringArray()

static jobjectArray Ocean::Platform::Android::Utilities::toJavaStringArray ( JNIEnv *  env,
const Strings strings 
)
static

Converts a vector of std strings to a Java array with native strings.

Parameters
envThe Java environment, must be valid
stringsStd strings to be converted, can be empty
Returns
Resulting Java native string

◆ toVector() [1/2]

static bool Ocean::Platform::Android::Utilities::toVector ( JNIEnv *  env,
jobject  javaIntegerList,
std::vector< int > &  values 
)
static

Converts a Java native list with integer to a vector of integers.

Parameters
envThe Java environment, must be valid
javaIntegerListJava list with integers to be converted, must be valid
valuesThe resulting vector of integers
Returns
True, if succeeded

◆ toVector() [2/2]

static bool Ocean::Platform::Android::Utilities::toVector ( JNIEnv *  env,
jobject  javaStringList,
Strings strings 
)
static

Converts a Java native list with string to a vector of strings.

Parameters
envThe Java environment, must be valid
javaStringListJava list with strings to be converted, must be valid
stringsThe resulting vector of strings
Returns
True, if succeeded

◆ triggerVibration()

static bool Ocean::Platform::Android::Utilities::triggerVibration ( JNIEnv *  env,
jobject  activity,
unsigned int  intensity = 1u,
const unsigned int  duration = 50u 
)
static

Triggers a vibration.

This function needs permission 'android.permission.VIBRATE'.

Parameters
envThe Java environment, must be valid
activityThe root activity from which the new activity will be started, must be valid
intensityThe intensity of the vibration, the higher the stronger, with range [0, 2]
durationThe duration of the vibration in milliseconds, with range [1, infinity)
Returns
True, if succeeded

The documentation for this class was generated from the following file: