Is it possible to open a Unity android app with intent ?

Hi !

i was wondering if it is possible to open a unity android app with intent from another app, the intent being a string (the path to a video file or files)

Thanks in advance!

In Android you launch Activities with an Intent, not an application. The application is launched but with the intent you actually tell android you want a list of activities for it. That’s why the “ACTION_SENDTO” intent shows you different apps, they all have an activity that responds to that intent.

For an activity to respond to an intent you have to setup the android manifest with that info. Look here: Intents and intent filters  |  Android Developers

Now, in Unity you can add your custom manifest as an asset, and Unity will use that manifest (I think it actually merges your manifest with the default manifest). In that custom manifest you can set the intents that will launch the Unity activity, which is “com.unity3d.player.UnityPlayerNativeActivity”.

You can respond to the standard intents or you can use a URL scheme. Whatever you do, you need to add the path to the intent, that’s done with the “putExtra” method in java.

If you want to send some info (the path of a file) it means you have to read that info from within Unity. Something like this should work:

AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		AndroidJavaObject context = jc.GetStatic<AndroidJavaObject>("currentActivity");
		AndroidJavaObject intent = context.Call<AndroidJavaObject>("getIntent");
		return intent.Call<string>("getStringExtra","someKey"); //the key you used in the putExtra line on java

I’ve done all this and it works, but you’ll need some trial and error to get it right (the manifest merge is complicated and the testing and debugging is harder than normal stuff).