Search Unity

find out that a specific app is installed

Discussion in 'Android' started by charnold, Jan 24, 2016.

  1. charnold

    charnold

    Joined:
    Mar 31, 2014
    Posts:
    31
    What is the recommended way to find out that a specific app is installed on the device? (I have 2 apps with a sharedUserId and when starting one app, I want to verify, that the other app is installed)

    At the moment, I test that the folder "/data/data/<package_name_of_other_app>" exists. Both apps don't use WRITE_EXTERNAL_STORAGE in AndroidManifest, so this works , but maybe there is a better way?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    There's another way you can test for this but it involves creating a native plugin (in Java), i don't think you can do this directly from Unity...
     
  3. charnold

    charnold

    Joined:
    Mar 31, 2014
    Posts:
    31
    Another way? Which way? :)
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Are both these apps under your control? If so, you can have them respond to a particular URL scheme.

    For example, "WhatsApp" can be launched using URLs such as whatsapp://blablabla

    For your apps, you can register your own custom (unique) URL scheme, then at runtime check whether you can open that URL. On Android, this means something like asking "can any app open the intent with this URL?"

    This is a technique we have used in our game. Let me know if this helps or whether you need further assistance :)