- Home /
Open the right android activity with arguments
Hi!
In my application, I would like to open another android app (Adobe Reader) to read a pdf file. I have to mention that I developed most of my apps on Unity, and therefore I am not very familiar with the intents and the activities. However, by searching on the internet, I have found those lines of code, which allow me to open correctly the Adobe Reader application.
public void DocumentDisplay(){
bool fail = false;
string bundleId = "com.adobe.reader"; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
}
catch (System.Exception e)
{
fail = true;
}
if (fail)
{ //open app in store
Application.OpenURL("https://google.com");
}
else //open the app
ca.Call("startActivity",launchIntent);
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}
What I would like to do now is to open directly the right file, instead of opening the main "start" activity of adobe Reader. First I don't know which activity of the Adobe Reader app corresponds to the one which reads the file. I downloaded the apk file of the app, and analyzed it in Android studio, to access to the manisfest file, but it didn't help me to find a solution. I don't really understand how I am supposed to call the right function with the right argument without knowing how the applications is coded.
So could you help me and show me the way to do such a thing?
Thanks!
Antoine
Your answer
Follow this Question
Related Questions
How do i stop mUnityPlayer.quit() closing the entire android app? 1 Answer
Disable permission dialog in Unity 5 2 Answers
How to extend Activity (Android)? 1 Answer
Android Unity, Screen Recording and MediaProjection APIs - UnityPlayerActivity hang. 0 Answers
How to open transparent activity from UnityPlayerActivity? 0 Answers