Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by DanjelRicci · Jan 29, 2014 at 09:49 AM · androiddetectionappinstalled

Detect if app is installed on Android

We are developing a Unity application which needs to check if certain apps are already installed or not on the device. We managed to do this easily on iOS using PlayerPrefs and Xcode, but we don't know how to do the same on Android.
There are lots of questions like this on the web but no one applies dircetly to Unity, so we are in need for some help or hints. Thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tanveerm · Aug 12, 2016 at 02:59 PM 0
Share

@DanjelRicci , how did you manage to get it to work on IOS? can you please explain

1 Reply

· Add your reply
  • Sort: 
avatar image
10

Answer by alok_androider · Jun 20, 2014 at 05:31 PM

     public  bool IsAppInstalled(string bundleID){
 #if UNITY_ANDROID
         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",bundleID);
             //        
             //        ca.Call("startActivity",launchIntent);
         }catch(Exception ex){
             Debug.Log("exception"+ex.Message);
         }
         if(launchIntent == null)
             return false;
         return true;
 #else
         return false;
 #endif
Comment
Add comment · Show 14 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image abi-kr01 · Feb 06, 2015 at 07:19 AM 0
Share

say i want a button which will open the other app like Skype/viber or anything that can have bundle id on android ,else it will redirect it to redirect to google can we do that .

i mean will catch of (try-catch ) execute so that i can put application.openurl

avatar image alok_androider · Feb 06, 2015 at 08:46 AM 0
Share

You're absolutely right. You should use the Catch for opening the playstore by calling Application.OpenURL.

avatar image xnimbus · Feb 06, 2015 at 05:44 PM 0
Share

The solution works great if I had to test if app is installed, But in my case I need to know if app is not installed.

  launchIntent = package$$anonymous$$anager.Call<AndroidJavaObject("getLaunchIntentForPackage",bundleID);

throws Java exception which is not caught by c# catch statement, which breaks further code execution. Can you suggest workaround? I would be thankful if any solution provided. False is never returned in this case

avatar image alok_androider · Feb 07, 2015 at 04:23 AM 0
Share

Hey, i have updated the answer, we need to handle Exception not UnityException. Cheers. @royperetz , What problem you are facing and do you need to check installed apps Android or Ios

avatar image xnimbus · Feb 07, 2015 at 06:02 AM 0
Share

Thank you, I ended up creating android plugin and handled exception in plugin, But if exception works then this is even great

avatar image royperetz xnimbus · Nov 02, 2015 at 11:24 AM 0
Share

Hi! I have the same problem, can you share your solution? What plugin should i use? Thnx

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make an android app a "trial" version 2 Answers

Signing an Android application 1 Answer

Why does .apk file being built consumes so much space? 1 Answer

Detect if app is installed on iOS 0 Answers

ultility app 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges