|
Ocean
|
This class implements helper functions for android platforms. More...
#include <Utilities.h>
Static Public Member Functions | |
| 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 std::vector< std::string > &strings) |
| Converts a vector of std strings to a Java array with native strings. | |
| static bool | toVector (JNIEnv *env, jobject javaStringList, std::vector< std::string > &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 | 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. | |
This class implements helper functions for android platforms.
|
static |
|
static |
|
static |
Returns the class name of an object.
| env | The Java environment, must be valid |
| object | The object for which the class name will be returned, must be valid |
| name | The resulting class name |
|
static |
Joins a Wi-Fi network (WPA2-PSK).
This only works with Android SDK version 28 or below.
| env | The Java environment, must be valid |
| activity | The root activity from which the new activity will be started, must be valid |
| ssid | The Wi-Fi network name (SSID), the network must be using WPA2, must be valid |
| password | The Wi-Fi network password, must be valid |
|
static |
Returns current Wi-Fi network name (SSID).
| env | The Java environment, must be valid |
| activity | The root activity from which the new activity will be started, must be valid |
| ssid | The resulting Wi-Fi network name (SSID), will be empty if there is no Wi-Fi connection |
|
static |
Returns the name of the package.
| packageName | The resulting package name |
|
static |
Returns the brand string of the device.
| env | The Java environment, must be valid |
| brand | The resulting model string |
|
static |
Returns the model string of the device.
| env | The Java environment, must be valid |
| model | The resulting model string |
|
static |
Returns the minimum and target SDK versions stored in the application manifest.
| env | The Java environment, must be valid |
| activity | The Android main activity, must be valid |
| minSdkVersion | The resulting minimum SDK version of the application as defined in its manifest |
| targetSdkVersion | The resulting target SDK version of the application as defined in its manifest |
|
static |
Returns the version code stored in the application manifest.
| javaVM | The Java virtual machine, must be valid |
| activity | The Android main activity, must be valid |
| versionCode | The resulting version code of the application |
| versionName | The resulting version name of the application |
|
static |
Deprecated.
Returns the version code stored in the application manifest.
| javaVM | The Java virtual machine, must be valid |
| activity | The Android main activity, must be valid |
| versionCode | The version code of the application |
|
static |
Sends an explicit intent to another component or application.
| env | The Java environment, must be valid |
| activity | The Android main activity, must be valid |
| packageName | The name of the package to which the intent will be sent, must be valid |
| className | The name of the class or activity to which the intent will be sent, must be valid |
| extraText | The data that will be sent with the intent, must be valid |
|
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:
android.permission.CHANGE_NETWORK_STATE and android.permission.WRITE_SETTINGS to be set in the app manifest to work.android.permission.CHANGE_NETWORK_STATE again. Re-tries are possible.Settings.ACTION_WIFI_ADD_NETWORKS. Otherwise this function will have no effect (and still return true). | env | The Java environment, must be valid |
| activity | The root activity from which the new activity will be started, must be valid |
| ssid | The Wi-Fi network name (SSID), the network must be using WPA2, must be valid |
| password | The Wi-Fi network password, must be valid |
|
static |
Starts an new activity from a root activity.
| env | The Java environment, must be valid |
| rootActivity | The root activity from which the new activity will be started, must be valid |
| activityClassName | The name of the class of the activity to start, must be valid |
|
static |
Returns the value of a specific system property.
| name | The name of the system property, must be valid |
| value | The resulting value |
|
static |
Converts a Java native string to a std string.
| env | The Java environment, must be valid |
| javaString | Java string to be converted, may be nullptr |
|
static |
Converts a std string to a Java native string.
| env | The Java environment, must be valid |
| stdString | Std string to be converted |
|
static |
Converts a vector of std strings to a Java array with native strings.
| env | The Java environment, must be valid |
| strings | Std strings to be converted, can be empty |
|
static |
Converts a Java native list with integer to a vector of integers.
| env | The Java environment, must be valid |
| javaIntegerList | Java list with integers to be converted, must be valid |
| values | The resulting vector of integers |
|
static |
Converts a Java native list with string to a vector of strings.
| env | The Java environment, must be valid |
| javaStringList | Java list with strings to be converted, must be valid |
| strings | The resulting vector of strings |
|
static |
Triggers a vibration.
This function needs permission 'android.permission.VIBRATE'.
| env | The Java environment, must be valid |
| activity | The root activity from which the new activity will be started, must be valid |
| intensity | The intensity of the vibration, the higher the stronger, with range [0, 2] |
| duration | The duration of the vibration in milliseconds, with range [1, infinity) |