How to access native Android services from a Gluon

2019-07-29 17:10发布

问题:

I'd like to call native services from my very basic Gluon Mobile application on an Android device. For example, by how it's done in the GoNative sample application, I can obtain a TelephonyManager instance like this:

 TelephonyManager telephonyManager= (TelephonyManager)FXActivity.getInstance().getSystemService(android.content.Context.TELEPHONY_SERVICE);

But the example seems not to be up to date. I see that it uses earlier versions of several libs in die build.gradle file while in my config, the 3.0.0versions are used.

It seems that there were API changes as FXActivity doesn't even offer the getSystemService() function anymore.

So, in the current version, how can I obtain a TelephonyManager and access the rest of the native Android services?