Accessing Android PackageManager

Hi guys, I’m starting with Uno and Foreign Code. At this moment, I’m trying to access the PackageManager. I saw at the forum someone doing something like this and he used simply

PackageManager pm = getPackageManager();

Well, I tried it also, but in my case when I try to preview it it returns me an error:

[javac]         PackageManager pm = getPackageManager();
[javac]         ^
[javac]   symbol:   class PackageManager
[javac]   location: class Flashlight
[javac]         PackageManager pm = getPackageManager();
[javac]                             ^
[javac]   symbol:   method getPackageManager()

so I just added

[ForeignInclude(Language.Java, "android.content.pm.PackageManager")]

and now I only get the error

[javac]         PackageManager pm = getPackageManager();
[javac]                             ^
[javac]   symbol:   method getPackageManager()

My question is, there is anything extra that is not in the documentation that I need to do to solve this error?

Fuse version

Fuse version 0.29.0 (build 8396)

Operating system and version

ProductName:	Mac OS X
ProductVersion:	10.12.1

Hello Ana,

The error implies that the method can’t be found (you might get more details if you compile with -v by the way), so you’ll have to look up what class it’s contained in and how you can get an instance of that class.

In this case I’m guessing you want the root activity, which you can get in foreign Java as follows:

com.fuse.Activity.getRootActivity().getPackageManager()

Hope that helps!

It worked. Thanks, Olle.