[Gear VR] How to do the required volume UI?

It does not appear to be possible to do the required volume UI in UE4 binary using blueprints.

It is required for any submission to Oculus store. See:




There appears to be something in the Oculus SDK documentation about it such as: https://developer.oculus.com/doc/

I tried creating my own volume UI 3d widget using the assets from the GearVR Mobile SDK however I can’t figure out how to get the current volume. Without knowing the current volume you do not know what value to show in the UI.

Can we get these exposed to the blueprints? Otherwise UE4 is still not supporting the entire GearVR distribution process

EDIT: in 4.13 the volume UI is working out of the box and you don’t need to do anything at all! :wink:

If all you need is to get the current volume, you can add a “GetCurrentVolume” Blueprint node by adding the following and rebuilding the editor and Android .so:

In GameActivity.java:

public int AndroidThunkJava_GetCurrentVolume()
	AudioManager audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
	return audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

In AndroidJNI.h to FJavaWrapper:

static jmethodID AndroidThunkJava_GetCurrentVolume;

static int32 CallIntMethod(JNIEnv* Env, jobject Object, jmethodID Method, ...);

In AndroidJNI.cpp to FJavaWrapper::FindClassesAndMethods:

AndroidThunkJava_GetCurrentVolume = FindMethod(Env, GameActivityClassID, "AndroidThunkJava_GetCurrentVolume", "()I", bIsOptional);

Add to //Declare all the static members of the class defs:

jmethodID FJavaWrapper::AndroidThunkJava_GetCurrentVolume;

Add these functions:

int32 FJavaWrapper::CallIntMethod(JNIEnv* Env, jobject Object, jmethodID Method, ...)
	if (Method == NULL || Object == NULL)
		return false;

	va_list Args;
	va_start(Args, Method);
	jint Return = Env->CallIntMethodV(Object, Method, Args);

	return (int32)Return;

int32 AndroidThunkCpp_GetCurrentVolume()
	int32 Result = 0;
	if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
	Result = FJavaWrapper::CallIntMethod(Env, FJavaWrapper::GameActivityThis, FJavaWrapper::AndroidThunkJava_GetCurrentVolume);
	return Result;

Add to KismetSystemLibrary.h:

* Returns the current volume (Android only)
UFUNCTION(BlueprintPure, Category = "Utilities|Platform")
static int32 GetCurrentVolume();

Add to KismetSystemLibrary.cpp:

int UKismetSystemLibrary::GetCurrentVolume()
	extern int32 AndroidThunkCpp_GetCurrentVolume();

	return AndroidThunkCpp_GetCurrentVolume();
	return 0;

Hi Chris thanks for the answer,

I’m not 100% sure if that is all that is required but I’ll give this a try in the next few days and post again if not!

Would be great to have this as a standard engine feature as well :wink:


Is this coming into 4.12 by chance ?

Still wondering whether it’s coming into 4.11.x or 4.12

Did this source code do the trick?
Did you get your app published in the Oculus Store yet?

Yes it worked and yes I got my game onto the gearvr store :slight_smile:

We Come In Peace…

Please note that some of the code Chris posted above did make it into the engine from 4.10 on. My guess is the stuff required for a code project made it in, however the stuff required to expose the ‘get current volume’ node to blueprints is still not in the engine as of 4.11 :frowning:
So yeah in case you have troubles compiling check that that part is not already there :wink:

You don’t have to be concerned with this any longer as Low Entry implemented this in their plugin: LE Extended Standard Library in Code Plugins - UE Marketplace

Plus battery charge and temperature.

This should provide missing functionality, plus battery charge and temperature: LE Extended Standard Library in Code Plugins - UE Marketplace

I’ve followed all the steps and compiled in Visual Studio but “GetCurrentVolume” node still refuses to appear. Does it have to be compiled somewhere else or I’m missing something obvious?

Thank you!

Thank you motorsep! You are being of a great help!

It would be much to ask how the ‘Get Volume’ node (from LE plugin) works? Cause I’ve tested it getting the volume and printing strings every time a volume button in gear is pressed, but the string does not seem to vary regardless of the phone’s volume. Have I to use this node to get the phone’s volume?

Thank you again!

I haven’t used it yet, but feel free to report bugs to the developer and ask for help/fixes here: Low Entry Plugins - Marketplace - Unreal Engine Forums

Hi TrujaSanguinaria, did you do the required volume UI in UE4?. I have downloaded the LE Extended plugin to my UE4.11.2 but I’m in the same situation… I don’t understand hoy the ‘Get Volume’ node is working :confused: Any help?

@Chris Babcock, I followed your instructions and tried to package an APK for Android platforms but I got this error(undefined reference to ‘AndroidThunkCpp_GetCurrentVolume()’):

Somehow my custom UE4 engine was built without any error. Could this be possible?

FYI: in 4.13 the volume UI is working out of the box and you don’t need to do anything at all! :wink:

FYI: in 4.13 the volume UI is working out of the box and you don’t need to do anything at all! :wink:

FYI: in 4.13 the volume UI is working out of the box and you don’t need to do anything at all! :wink:

If you really have to use an older version are you sure you compiled the engine for Android development and android shipping and not just windows client.

FYI: in 4.13 the volume UI is working out of the box and you don’t need to do anything at all! :wink: