- Home /
open another app from ours?
Hi, I want to open gallery from my android app. I found somewhere that you can do it using`Application.OpenURL`having gallery URI path in it. But I don't have a sun beam of idea to do it anyway. Can somebody know how to achieve it, opening certain app from our application. Thanks!
see this nice plugin it may help you to launch any other app in android and ios... http://unitydevelopers.blogspot.in/2017/06/launch-any-app-from-unity-android-ios.html
Answer by HarshadK · Nov 04, 2016 at 05:35 AM
Here are some of the solutions:
This link : (https://forum.unity3d.com/threads/android-ios-launch-from-within-a-unity-app-another-unity-app.222709/#post-1486300) is kinda similar to what I am looking for, but since I wanted to open Gallery, I don't know what activity to call or what Intent, I mean I just wanted to know what should I write for opening gallery activity.
Take a look at this code :
bool fail = false;
string bundleId = com.google.appname; //target bundle id for gallery!?
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject package$$anonymous$$anager = ca.Call<AndroidJavaObject>("getPackage$$anonymous$$anager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = package$$anonymous$$anager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
}
catch (System.Exception e)
{
fail = true;
}
if (fail)
{ //open app in store
Application.OpenURL("https://google.com");
}
else //I want to open Gallery App? But what activity?
ca.Call("startActivity",launchIntent);
up.Dispose();
ca.Dispose();
package$$anonymous$$anager.Dispose();
launchIntent.Dispose();
Now, I want to open gallery activity in the else block, Any Idea how can I do that? Thanks for sharing!!
I found my native android gallery's bundle ID, so I replaced the code above with this:
string bundleId = "com.android.gallery3d";
But it doesn't helps me either, it does not open anything!
Answer by DeveshPandey · Jan 07 at 07:13 AM
Hello,
Here is the simple code for iOS to launch any other installed app from your app. You have to put this objective c file in your Plugins/iOS folder and call the function. Here is the link which can help you.
http://unitydevelopers.blogspot.com/2017/06/launch-another-ios-app-from-your-app.html
Your answer
Follow this Question
Related Questions
Is possible to disable 3G connection in iOS and Android by Unity App? 1 Answer
Load image from Android-gallery on OS 5.0.1 0 Answers
Multiple Cars not working 1 Answer
Getting android device's IP 1 Answer
Distribute terrain in zones 3 Answers