VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Static Public Member Functions | List of all members
AndroidActivity Class Reference

JNI interface for the main Android activity. More...

Static Public Member Functions

static SelfDetachingJNIEnv getEnv (JavaVM *vm=nullptr)
 Returns the current JNI environment. More...
 
static JavaVM * getJavaVM ()
 Returns the currently cached reference to the JVM. More...
 
static jobject getActivity ()
 Returns the currently cached reference to the Android activity. More...
 
static jclass getActivityClass (JNIEnv *env, jobject activity=nullptr)
 Returns a cached global reference to the Android activity class. More...
 
static bool isStarted ()
 Returns whether or not the Android activity has been started previously, meaning all future JNI calls should be safe to make. More...
 
static void onCreate (JNIEnv *jni, jobject activity)
 Android activity onCreate lifecycle callback. More...
 
static void onStart ()
 Android activity onStart lifecycle callback. More...
 
static void onResume ()
 Android activity onResume lifecycle callback. More...
 
static void onPause ()
 Android activity onPause lifecycle callback. More...
 
static void onStop ()
 Android activity onStop lifecycle callback. More...
 
static void onDestroy (JNIEnv *jni, jobject activity)
 Android activity onDestroy lifecycle callback. More...
 
static void onControllerDisconnect (JNIEnv *, jobject, int deviceId)
 Android activity onControllerDisconnect callback indicating that a device identified by deviceId has disconnected. More...
 
static bool onGamepadMotionEvent (JNIEnv *jni, jobject, jobject motionEvent)
 Android activity onGamepadMotionEvent callback for an Android MotionEvent that originated from a gamepad device. More...
 
static bool onGamepadKeyEvent (JNIEnv *jni, jobject, jobject keyEvent)
 Android activity onGamepadKeyEvent callback for an Android KeyEvent that originated from a gamepad device. More...
 
static bool onTouchNavigationMotionEvent (JNIEnv *jni, jobject, jobject motionEvent)
 Android activity onTouchNavigationMotionEvent callback for an Android MotionEvent that originated from a touch navigation device. More...
 
static bool onTouchNavigationKeyEvent (JNIEnv *jni, jobject, jobject keyEvent)
 Android activity onTouchNavigationKeyEvent callback for an Android KeyEvent that originated from a touch navigation device. More...
 
static bool onKeyboardKeyEvent (JNIEnv *jni, jobject, jobject keyEvent)
 Android activity onKeyboardKeyEvent callback for an Android KeyEvent that originated from a keyboard device. More...
 
static void onSignedIntoCloudChanged (JNIEnv *, jobject, bool signedIntoCloud)
 Android activity onSignedIntoCloudChanged callback indicating that cloud (i.e. GPGS) sign-in status has changed. More...
 
static void onCloudDataLoaded (JNIEnv *jni, jobject, int statusCode, jstring javaData)
 Android activity onCloudDataLoaded callback when cloud (i.e. GPGS) save data has been loaded. More...
 
static jstring onCloudDataConflict (JNIEnv *jni, jobject, jstring local, jstring cloud)
 Android activity onCloudDataConflict callback indicating a conflict of cloud (i.e. GPGS) save data has been detected while loading. More...
 
static bool isSignedIntoCloud ()
 Returns true if currently signed into the cloud (i.e. GPGS). More...
 
static bool cloudSignInFailed ()
 Returns true if the most recent cloud (i.e. GPGS) sign in attempt failed. More...
 
static void signIntoCloud ()
 Begins asynchronous cloud (i.e. GPGS) sign in. More...
 
static void signOutOfCloud ()
 Signs out of cloud (i.e. GPGS). More...
 
static bool ensureCloudSync ()
 Starts a cloud (i.e. GPGS) save game data sync. More...
 
static void saveToCloud (const QString &data)
 Saves p data to the cloud (i.e. GPGS). More...
 
static void clearCloudData ()
 Resets any cloud (i.e. GPGS) save game data. More...
 
static bool revealAchievement (const QString &name)
 Reveals a GPGS achievement. More...
 
static bool unlockAchievement (const QString &name)
 Unlocks a GPGS achievement. More...
 
static bool incrementAchievement (const QString &name, int numSteps)
 Increments a GPGS incremental achievement. More...
 
static bool setAchievementSteps (const QString &name, int minSteps)
 Sets a GPGS incremental achievement to have a minimum number of steps. More...
 
static void showAchievementsRequested ()
 Launch an intent to show the GPGS achievements activity screen. More...
 
static void resetAchievementsRequested ()
 Resets all GPGS achievement progress for the currently signed in user account. More...
 
static QString getVersionName ()
 Returns the version string of the Android application. More...
 
static long getMemoryUsed ()
 Returns the number of bytes allocated for the native heap. More...
 
static int getTouchScreenDeviceId ()
 Returns the hardware deviceId of the touch screen input device, or -1 if none. More...
 
static void clearBGMTrack (int priority)
 Clears the Android SoundManager's BGM track at the specified priority level. More...
 
static void setBGMTrack (int priority, const QString &track)
 Sets the Android SoundManager's BGM track at the specified priority level to track. More...
 
static bool isBGMMuted ()
 Returns whether or not the Android SoundManager's background music is muted. More...
 
static void setBGMMuted (bool value)
 Sets the Android SoundManager's muted state. More...
 
static void setBGMPaused (bool value)
 Sets the Android SoundManager's paused state. More...
 
static void setTrackerScreenName (const QString &screenName, bool sendScreenView=true)
 Sets the Google Analytics screen name and optionally sends a screen view hit. More...
 
static void sendTrackerEvent (const QString &category, const QString &action)
 Sends an event hit to Google Analytics. More...
 
static void sendTrackerEvent (const QString &category, const QString &action, const QString &label)
 Sends an event hit to Google Analytics. More...
 
static void sendTrackerEvent (const QString &category, const QString &action, const QString &label, long value)
 Sends an event hit to Google Analytics. More...
 
static void sendTrackerEvent (const QString &category, const QString &action, long value)
 Sends an event hit to Google Analytics. More...
 

Detailed Description

JNI interface for the main Android activity.

This static class contains both native callbacks used by the Android activity and methods that invoke their Java counterpart.

Note
Users of this class should be aware of the different calling threads and contexts which exist. Native callbacks are executing on the Android Ui (i.e. main activity looper thread), but this thread is typically synchronized against the native Qt Ui thread and should not generally pose thread-safety issues.
Native callbacks first two parameters are always the current JNI environment (a JNIEnv pointer) and a reference (a jobject) to the invoking Android activity, unless the function has no additional parameters in which case they can be removed. The convention assumed for this class is to make either of these first two parameters nameless if they are unused in the callback (i.e. the callback does not make calls back across the JNI boundary into Java).

Member Function Documentation

static void AndroidActivity::clearBGMTrack ( int  priority)
static

Clears the Android SoundManager's BGM track at the specified priority level.

Note
See SoundManager::clearBGMTrack for more details.
Parameters
priorityPriority level of BGM to clear
static void AndroidActivity::clearCloudData ( )
static

Resets any cloud (i.e. GPGS) save game data.

static bool AndroidActivity::cloudSignInFailed ( )
static

Returns true if the most recent cloud (i.e. GPGS) sign in attempt failed.

static bool AndroidActivity::ensureCloudSync ( )
static

Starts a cloud (i.e. GPGS) save game data sync.

Note
Must be signed into cloud to have this method return anything other than false.
Returns
true if a cloud sync has been started successfully
static jobject AndroidActivity::getActivity ( )
inlinestatic

Returns the currently cached reference to the Android activity.

static jclass AndroidActivity::getActivityClass ( JNIEnv *  env,
jobject  activity = nullptr 
)
static

Returns a cached global reference to the Android activity class.

Note
If currently unavailable, this method will load the activity class from env by either looking through the CLASSPATH for the class or by retrieving the class of activity if it is provided.
Parameters
envEnvironment to load the activity class from
activityOptional activity object to use for class loading
static SelfDetachingJNIEnv AndroidActivity::getEnv ( JavaVM *  vm = nullptr)
static

Returns the current JNI environment.

Note
This method will cache the JVM reference so future calls do not need to provide it.
Parameters
vmJavaVM to load the current environment from
static JavaVM* AndroidActivity::getJavaVM ( )
inlinestatic

Returns the currently cached reference to the JVM.

static long AndroidActivity::getMemoryUsed ( )
static

Returns the number of bytes allocated for the native heap.

static int AndroidActivity::getTouchScreenDeviceId ( )
static

Returns the hardware deviceId of the touch screen input device, or -1 if none.

Note
If multiple touch screen devices are present, this returns the id of the first one discovered.
static QString AndroidActivity::getVersionName ( )
static

Returns the version string of the Android application.

static bool AndroidActivity::incrementAchievement ( const QString name,
int  numSteps 
)
static

Increments a GPGS incremental achievement.

Parameters
nameAndroid resource name used to locate the achievement id
numStepsNumber of steps to increment the achievement
Returns
true if the achievement was successfully incremented
static bool AndroidActivity::isBGMMuted ( )
static

Returns whether or not the Android SoundManager's background music is muted.

Note
See SoundManager::isBGMMuted for more details.
static bool AndroidActivity::isSignedIntoCloud ( )
static

Returns true if currently signed into the cloud (i.e. GPGS).

static bool AndroidActivity::isStarted ( )
inlinestatic

Returns whether or not the Android activity has been started previously, meaning all future JNI calls should be safe to make.

static void AndroidActivity::resetAchievementsRequested ( )
static

Resets all GPGS achievement progress for the currently signed in user account.

Note
This function is for debug / testing purposes only and will not work on GPGS accounts no longer in staging.
static bool AndroidActivity::revealAchievement ( const QString name)
static

Reveals a GPGS achievement.

Parameters
nameAndroid resource name used to locate the achievement id
Returns
true if the achievement was successfully revealed
static void AndroidActivity::saveToCloud ( const QString data)
static

Saves p data to the cloud (i.e. GPGS).

Parameters
dataUTF-8 encoded save game data to save
static void AndroidActivity::sendTrackerEvent ( const QString category,
const QString action 
)
static

Sends an event hit to Google Analytics.

Parameters
categoryCategory in which the event will be filed
actionAction associated with the event
static void AndroidActivity::sendTrackerEvent ( const QString category,
const QString action,
const QString label 
)
static

Sends an event hit to Google Analytics.

Parameters
categoryCategory in which the event will be filed
actionAction associated with the event
labelDescriptive label used for further differentiation of categorical actions
static void AndroidActivity::sendTrackerEvent ( const QString category,
const QString action,
const QString label,
long  value 
)
static

Sends an event hit to Google Analytics.

Parameters
categoryCategory in which the event will be filed
actionAction associated with the event
labelDescriptive label used for further differentiation of categorical actions
valueValue to be logged with the event
static void AndroidActivity::sendTrackerEvent ( const QString category,
const QString action,
long  value 
)
static

Sends an event hit to Google Analytics.

Parameters
categoryCategory in which the event will be filed
actionAction associated with the event
valueValue to be logged with the event
static bool AndroidActivity::setAchievementSteps ( const QString name,
int  minSteps 
)
static

Sets a GPGS incremental achievement to have a minimum number of steps.

Parameters
nameAndroid resource name used to locate the achievement id
minStepsLower bound for incremental progress
Returns
true if the achievement was successfully set to minSteps
static void AndroidActivity::setBGMMuted ( bool  value)
static

Sets the Android SoundManager's muted state.

Parameters
valuetrue if muting BGM
static void AndroidActivity::setBGMPaused ( bool  value)
static

Sets the Android SoundManager's paused state.

Note
See SoundManager::setPaused for more details.
Parameters
valuetrue if pausing BGM
static void AndroidActivity::setBGMTrack ( int  priority,
const QString track 
)
static

Sets the Android SoundManager's BGM track at the specified priority level to track.

Note
See SoundManager::setBGMTrack for more details.
Parameters
priorityPriority level of BGM to set
trackName of track to use for BGM
static void AndroidActivity::setTrackerScreenName ( const QString screenName,
bool  sendScreenView = true 
)
static

Sets the Google Analytics screen name and optionally sends a screen view hit.

Parameters
screenNameName of screen to be set
sendScreenViewtrue if a screen view hit should be sent
static void AndroidActivity::showAchievementsRequested ( )
static

Launch an intent to show the GPGS achievements activity screen.

static void AndroidActivity::signIntoCloud ( )
static

Begins asynchronous cloud (i.e. GPGS) sign in.

static void AndroidActivity::signOutOfCloud ( )
static

Signs out of cloud (i.e. GPGS).

static bool AndroidActivity::unlockAchievement ( const QString name)
static

Unlocks a GPGS achievement.

Parameters
nameAndroid resource name used to locate the achievement id
Returns
true if the achievement was successfully unlocked