Ejemplo n.º 1
0
    //Returns true if YipliApp is installed, else returns false
    public static bool IsYipliAppInstalled()
    {
#if UNITY_EDITOR
        return(true);
#elif UNITY_ANDROID
        AndroidJavaObject launchIntent = null;
        try
        {
            AndroidJavaClass  up             = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject ca             = up.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject packageManager = ca.Call <AndroidJavaObject>("getPackageManager");
            Debug.Log(" Quering if Yipli App is installed.");

            //if the app is installed, no errors. Else, doesn't get past next line

            launchIntent = packageManager.Call <AndroidJavaObject>("getLaunchIntentForPackage", yipliAppBundleId);
        }
        catch (Exception ex)
        {
            Debug.Log("exception" + ex.Message);
        }
        if (launchIntent == null)
        {
            Debug.Log("Yipli app is not installed.");
            return(false);
        }

        Debug.Log("Yipli App is Installed. Returning true.");
        return(true);
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR // TODO : Handle Windows flow
        Debug.Log("Yipli App validation for windows isnt required. Returning true");
        return(FileReadWrite.IsYipliPcIsInstalled());
#else
        Debug.Log("OS not supported. Returnin false.");
        return(false);
#endif
    }