I recently started programming, and I don’t have enough experience yet - so I ask you to help ...
I use Unity 2020, and the task arose to open games that are on the phone, for example, a gallery and other applications that are on the phone (not to open a link on the Internet, but an application on the phone), I have a code that makes it possible to control, for example, a browser located in the scene, while all this happens in my application, but I still wanted to know if this is possible, only not with the pages on the Internet, but with the applications themselves on the smartphone ... Thanks in advance!
ok, so for launch camera app you can use only C#:
static int REQUEST_IMAGE_CAPTURE = 1;
public void StartPlugin()
{
AndroidJavaClass IntentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject IntentObject = new AndroidJavaObject("android.content.Intent");
AndroidJavaObject MSObject = new AndroidJavaObject("android.provider.MediaStore");
IntentObject.Call<AndroidJavaObject>("setAction", MSObject.GetStatic<string>("ACTION_IMAGE_CAPTURE"));
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivityForResult", IntentObject, REQUEST_IMAGE_CAPTURE);
}
and for launch app like viber, youtube you can use this code:
private string package = "com.viber.voip";
public void Launch()
{
AndroidJavaClass activityClass;
AndroidJavaObject activity, packageManager;
AndroidJavaObject launch;
activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
activity = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
packageManager = activity.Call<AndroidJavaObject>("getPackageManager");
launch = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", package);
activity.Call("startActivity", launch);
}
the package variable it is application id have a nice day!!! =)
For some applications (such as YouTube, Facebook) you can use
Application.OpenURL("http://unity3d.com/");
but this only works if you know the app link, for social media you can try the links until you find one that opens the app.
I haven't tried to do this with other apps, but if you can get the URL of the app (it's not too hard), you should be able to do it.