0

I have an android project (let's call this Base) in which I have added/imported a new project. Now, I have to open an activity in the new project (imported module) from the Base project.

How could this be achieved?

From the screenshot, I want to open UnityPlayerActivity in a class under androidLauncher package

enter image description here

I tried using packageManager,

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.unity3d.player.UnityPlayerActivity");
                if (launchIntent != null) {
                    startActivity(launchIntent);
                }

This did not work as it is not getting the package name.

Edit: added root structure for the manifest files Manifest file structure

  • 1
    "How could this be achieved?" -- if `unityLibrary` is a library module, and you add it to the `app` module as a dependency, then you would use `new Intent(context, UnityPlayerActivity.class)`, where `context` is some `Context`, such as an `Activity`. "I tried using packageManager" -- `PackageManager` is for working with other apps on the device. – CommonsWare Apr 18 '22 at 21:33
  • I have added the UnityLibrary as a module and as you can see, it has its own manifest too. Now, if I were to use the normal intent to open the UnityPlayerActivity, I have to declare it in the main project's manifest which is not happening because the main project does not know about the UnityLibrary. – Abhishek sheshagiri Apr 18 '22 at 21:43
  • "if I were to use the normal intent to open the UnityPlayerActivity, I have to declare it in the main project's manifest" -- library module manifests get merged into your overall app manifest. So, see if your merged manifest (in the "Merged Manifest" sub-tab of the manifest editor in Android Studio) has an entry for `UnityPlayerActivity`. – CommonsWare Apr 18 '22 at 21:48
  • I do not see that. I tried even adding ```tools:node="merge"``` in the library manifest file. Update the description with the root structure of the project. – Abhishek sheshagiri Apr 18 '22 at 21:54
  • Then either you need to talk to the developer of `unityLibrary` and have them add an entry to that library's manifest, or you need to add the entry to your `app` module's manifest. An activity cannot be started, by any possible means, without it being in your app's manifest. – CommonsWare Apr 18 '22 at 21:55
  • Are you getting any errors? If so, what is it? – Code-Apprentice Apr 18 '22 at 21:57
  • yes, @Code-Apprentice. It obviously throws a No Class def in Manifest error. – Abhishek sheshagiri Apr 18 '22 at 22:00
  • How could I add an entry to the ```unityLibrary``` activity in the main manifest file? Is there a way now that I have the source added as a lib/module? @CommonsWare – Abhishek sheshagiri Apr 18 '22 at 22:01
  • 1
    "How could I add an entry to the unityLibrary activity in the main manifest file?" -- the same way you would for any other activity, by adding an `` element. You probably have some of these. You should talk to the developer of that library to determine how best to do this. – CommonsWare Apr 18 '22 at 22:10
  • The error isn't obvious to me. You might want to edit your question to include this details. – Code-Apprentice Apr 18 '22 at 23:26

0 Answers0