Back button event not passed at Android library through Unity and other problems

Hello,

I am quite new at Unity and I am trying to create a Unity plugin for an Android library and I ma facing the following issues:

  1. I can’t find a way to pass the back button event to Android library. What I have managed to do is to pass touch events to the activity on the Android side by setting the following line

at <activity android:name=“com.unity3d.player.UnityPlayerProxyActivity” … > in the AndroidManifest

However I cannot pass the back button event in a way that I do not have to change the code in the library

What I do for now in my script is

public void Update() {

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

However I need the option to pass that back event that I capture, to the library and not handle it at the Unity layer.

  1. I am trying to reference in my script an enum that I have in my Android library.

For example I have the following enum in a Place.java file

package com.myapp.constants;

public enum Place {
TOP, BOTTOM, RIGHT, LEFT
}

and I want to find a way to reference it from my script.

I tried something like that:

AndroidJavaClass topPlace = new AndroidJavaClass(“com.myapp.constants.TOP”);

but with no luck.

Can anyone help on those issues? Any help appreciated…

1 Like

If you want to use back button on android u can make a plugin and override Android onBackPressed function to send Unity a message. There are lots of resources that you can find to make a plugin for Unity android, I have also started to write tutorials for that at my blog you can check it out
http://nevzatarman.wordpress.com/

Thank you for your response. However this is not what I am asking here. I already have a jar library and I just want to pass the events from unity to that. I do not want to change the code in the jar. Just make the bridge between unity and the library