1

I don't want to use Input.GetKeyDown(KeyCode.Escape) to call back button, because in gradle build, The function has been done in unity, but then unity minimizes the application as well, I only want to get:

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

inside unity. because I don't want to minimize the game.

BlackMB
  • 230
  • 6
  • 20
  • This question is confusing. You want to detect when Android button is pressed from Java side? – Programmer Oct 13 '17 at 20:15
  • in gradle build, unity call an extra function for minimizing game when I use Input.GetKeyDown(KeyCode.Escape). – BlackMB Oct 13 '17 at 20:21
  • @Programmer its very important to me... – BlackMB Oct 13 '17 at 20:42
  • How do you you know if Unity is calling a function when you use `Input.GetKeyDown(KeyCode.Escape)`? I know you need `Input.GetKeyDown(KeyCode.Escape)` but what happens if you don't use `Input.GetKeyDown(KeyCode.Escape)`? – Programmer Oct 13 '17 at 21:40
  • @Programmer because before i build with gradle, it works fine. and after that when in UnityPlayerActivity.java, '@Override public boolean onKeyDown(int keyCode, KeyEvent event){ return mUnityPlayer.injectEvent(event); }' calls, it minimized game. – BlackMB Oct 13 '17 at 21:44
  • I really want to help you but don't understand the source of your issue. You blamed the problem on `Input.GetKeyDown(KeyCode.Escape)` but now you talking about `boolean onKeyDown`. These are not the-same and I don't know what to tell you – Programmer Oct 13 '17 at 21:46
  • @Programmer Input.GetKeyDown(KeyCode.Escape) works in unity, but when i build it with gradle, it works again, but minimize my game too. i don't want to minimize my game. only want to get true or false from this boolean. – BlackMB Oct 13 '17 at 21:48
  • Add this to the Activity in your Manifest ``. If this does not work change it to `` and see what happens. [This](https://stackoverflow.com/questions/43293173/use-custom-manifest-file-in-unity) post explains how to add manifest to your program. I will be back to see what happens – Programmer Oct 13 '17 at 21:54
  • @Programmer nope. minimize the game again with both meta-data. – BlackMB Oct 13 '17 at 22:20
  • I suggest you file for a bug report from Unity Editor. – Programmer Oct 14 '17 at 00:24

0 Answers0