1

I have an Android Studio project, generated from a Unity3d Project.

I wanted to run my project on a Google Glass so I followed this tutorial (http://forum.unity3d.com/threads/how-to-build-for-google-glass.219558/).

Everything works fine so far, but I can't close the app via swipe down, even though I added this to the UnityPlayerActivity.java:

@Override public boolean onKeyDown(int keyCode, KeyEvent event)   {
    if(keyCode == KeyEvent.KEYCODE_BACK){ finish(); }
    return true;
}

Again, everything else works just fine.


1st UPDATE:

I tried the application on a tablet - like on the Glass, "Back"-button does not work.

Then I implemented this in Unity:

if(Input.GetKeyDown(KeyCode.Escape)){
    Application.Quit();
}

Now it works on the tablet, but the Glass-situation did not change.


2nd UPDATE:

This also didn't work: this.finishAffinity();


3rd UPDATE:

I tried to close my Unity Application using this Coroutine in the Start()-Method:

IEnumerator waitAndExit(int sec)
{
    yield return new WaitForSeconds(sec);
    Application.Quit();
}

This successfully shuts down my application, so the problem appears to be this:

Unity does not recognize swiping down on Google Glass as a keyEvent in Input and the UnityPlayer object seems to get ALL input from android.

How can I stop that?
I wan't to handle touchpad events with java, but my original idea - overriding onKeyDown - did not work.


4th Update:

I tried to recognize a gesture like in this answer and added this to my onCreate():

mUnityPlayer.setFocusable(false);
//mUnityPlayer.requestFocus();

Unfortunately it did not help.

Community
  • 1
  • 1
000000000000000000000
  • 1,467
  • 1
  • 19
  • 38

1 Answers1

0

This is not really a solution, but rather a work-around:

Using contextual voice commands works fine, even with the UnityPlayer-object blocking touchpad input.

I now close my app via "OK glass - quit".


If anybody figures out how to solve it properly - I'll test, verify and accept your answer.

000000000000000000000
  • 1,467
  • 1
  • 19
  • 38