1

I have a unity game built, in C#, and an android app, in java. I would like to open the game from the android app as the app has some other functionalities that do not depend on the game.

I have never done integration of software before so I'm not sure how to proceed. I have thought about integrating the game within the app or have the game as a separate app on the phone and having the app opening it.

I would use this code fragment to launch the game from my main activity in android studio but I have some questions about it:

Button gameButton = (Button) findViewById(R.id.button_route_practice);
    gameButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = getPackageManager().getLaunchIntentForPackage("com.Author.DriveAppGame");
            startActivity(intent);
        }
    });

Where do I add my unity game package name for the app to find it?

How does android look for the game so that it actually starts it once the package name is found ?

  • Looks like [this thread](https://stackoverflow.com/questions/30446052/getlaunchintentforpackage-is-null-for-some-apps) can solve your problem. – SeLeCtRa Jan 26 '21 at 18:51

1 Answers1

0

I have never done what you are asking for, but I have exported Unity games to Android Studio where you can modify it's activities, maybe you could combine the exported project from Unity with your android app? You just need to check "Export project" in the Build Settings: Build Settings

Noge
  • 36
  • 2
  • I did that.. for some reason my game does not work as an android studio project. But when I build it as an apk and install it on my phone it works just fine. – user3402727 Jan 29 '21 at 18:47