0

I'm trying to make a launcher for cardboard apps in Unity.

My problem is that Unity doesn't provide a way to get all the VR apps installed in the phone (at least I don't know any), so I tried to make a plugin in Java to do that. Everything works fine, I can get the list of ApplicationInfo in Java and that way I can send information to Unity such as the number of these and their names.

My problem is that i can't send the image of the Icon of the apps, as Java uses a Drawable to get it from PackageManager.getApplicationIcon(), I can't access to it from Unity.

I've tried this:

private List<ApplicationInfo> cbApps; //list of ApplicationInfo already initialized

    public int[] getIcon(int i) {
        BitmapDrawable icon= (BitmapDrawable)getPackageManager().getApplicationIcon(cbApps.get(i));
        int[] result= new int[icon.getIntrinsicWidth()*icon.getIntrinsicHeight()];
        int p = 0;
        for(int j=0;j<icon.getIntrinsicWidth();j++)
            for(int k=0;k<icon.getIntrinsicHeight();k++){
                result[p]=icon.getBitmap().getPixel(j,k);
            }
        return result;
    }

But it only returns an array full of zeros (and sometimes a very bi positive or negative number) so it's not working as expected.

Any ideas on how to solve this?

Varu
  • 311
  • 1
  • 15

1 Answers1

0

Just for if someone comes to this queston I already found a solution and posted it in this other ask

Community
  • 1
  • 1
Varu
  • 311
  • 1
  • 15