Search code examples
androidjarvirtual-realitygoogle-cardboard

Detecting Cardboard native app


I'm building a VR app launcher, For this I'm running through the package manager of the installed apps and running the match command for "vr" in the packageName, which gives the result I need only if the developer have decided to add the word VR to his app name.

I'm wondering how will this detection can be made 100%.

The Manifest for a VR app doesn't seems to have any particular distinguished tag, VR apps must use a specific JAR and are running CardboardActivity instead of regular Activity, but I don't know how to search for this features.

Any help would be appreciated, Thanks.


Solution

  • The comment by random user was correct:

    Through the package manager one should read the intent of the application and search for the following intent : com.google.intent.category.CARDBOARD

        Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
        intentToResolve.addCategory("com.google.intent.category.CARDBOARD");
        intentToResolve.setPackage(appInfo.packageName);
        ResolveInfo ri = pm.resolveActivity(intentToResolve, 0);
    

    the ResolveInfo is !=null if intent is Cardboard app.