cancel
Showing results for 
Search instead for 
Did you mean: 

Unity Android Toast Msg and Download Manager

scopevcs
Explorer
Hey there,

I'm trying to notify the user in our Unity GearVR app about the current Download Status.

I've build a simple java plugin and can start the native download manager in the background when the user hits the download button.

But I do not know how to render android Toast Messages in the GearVR.
In a Unity 2D project the toast messages appear, but not in the GearVR project.

What is the best way to show android notifications in unity for VR?
Do I have to call the JavaClass functions on a specific thread, like the VR Thread? Because I try this at the moment:
activityContext.Call("runOnUiThread", new AndroidJavaRunnable(() => {
toastExample.Call("showMessage", "This is a Toast message");


But no message appears.

Unfortunately I find nothing about Unity and Android Notifcations or Download Managers for VR...
Doesn't have the OVR Unity plugin support for something like that because I find lot of android java functions in some of the SDK files but I do not know how to call them from unity...

Is there anyone who can help with this?

Thanks,
Phil
5 REPLIES 5

Anonymous
Not applicable
Do you REALLY need to use the Java api to display a notification?
It seems like having to invoke such lower-level implementation is more trouble than it is worth, considering you can slap a uGUI label in your game to display the status of your download method/coroutine.
For example (pseudo-code):

var scene: String;
var path: String;
var download: WWW;

function Start ()
{
download = WWW.LoadFromCacheOrDownload (path);
yield download;

// Handle error
if (download.error != null)
{
Debug.LogError(download.error);
return;
}

var bundle = download.assetBundle;
}

function Update ()
{
Debug.Log("Downloading"+download.progress);
}


Why go through the low level trouble for such a menial task?

bdjewkes
Explorer
I ran into the same problem with toasts as did the OP; they work in a regular android build, but not in VR mode. I never dug much deeper than that (as its easy enough to replicate the behavior from within Unity, as kilogold suggests), but I'd be curious to know if anyone has a solution, or at the very least an explanation of what the underlying issue is.

infinite360vr
Explorer

Sonar-360 said:

I've build a simple java plugin and can start the native download manager in the background when the user hits the download button.


How did you implement the plugin. I am trying to do the same. Any pointers?

Anonymous
Not applicable

infinite360vr
Explorer
Thanks a lot @gconvergen 🙂