Friday, October 8, 2021

Check android installed app

 

https://answers.unity.com/questions/627703/detect-if-app-is-installed-on-android.html

  1. public bool IsAppInstalled(string bundleID){
  2. #if UNITY_ANDROID
  3. AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  4. AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
  5. AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
  6. Debug.Log(" ********LaunchOtherApp ");
  7. AndroidJavaObject launchIntent = null;
  8. //if the app is installed, no errors. Else, doesn't get past next line
  9. try{
  10. launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleID);
  11. //
  12. // ca.Call("startActivity",launchIntent);
  13. }catch(Exception ex){
  14. Debug.Log("exception"+ex.Message);
  15. }
  16. if(launchIntent == null)
  17. return false;
  18. return true;
  19. #else
  20. return false;
  21. #endif

"market://details?q=pname:com.myCompany.myAppName/"

Application.OpenURL ("market://details?id=com.example.android"); misspellings

No comments:

Post a Comment