- Home /
How to check if Android app installed on the phone
I want to check if the Android app is installed on the phone, if not - open the Google Play. I tried this code:
`AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject> ("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject> ("getPackageManager");
Debug.Log (" ********LaunchOtherApp ");
AndroidJavaObject launchIntent = null;
//if the app is installed, no errors. Else, doesn't get past next line
try {
launchIntent = packageManager.Call<AndroidJavaObject> ("getLaunchIntentForPackage", "com.blah.blah");
ca.Call ("startActivity", launchIntent);
} catch (UnityException e) {
Debug.Log ("exception" + e.Message);
Application.OpenURL ("market://details?q=pname:com.blah.blah");
}`
But it isn't working, because there must be Exception, and not Unity Exception. Can anyone help me?
Comment