
NativeObjectUtils allows you to interact with objects native to the mobile platform. More...
Import Statement: | import Felgo 4.0 |
Since: | Felgo 3.3.0 |
This singleton type offers additional utility methods for dealing with NativeObjects. NativeObjectUtils is currently supported on Android and iOS.
You can obtain an instance to any native class with getClass().
On Android, you can access the app's Context with getContext(). You can also access the currently running Activity and/or Service with getActivity() and getService(). These methods can only be called on Android builds.
NativeObject getActivity() |
Returns a NativeObject instance representing the current Android Activity. If this method is called from a Service instead of an Activity, it will return null.
This method only exists on the Android platform. You can use the Qt global object to find out the currently running platform at runtime:
if(Qt.platform.os === "android") { var activity = NativeObjectUtils.getActivity() }
You can also use this property from within your NativeView::androidBinding implementation.
See also getContext() and getActivity().
NativeClass getClass(string className) |
Returns a NativeClass instance representing the Class className
of the native platform.
Note: On Android, separate packages in class names with "/"
. Separate nested classes with "$"
.
Example usage:
// get OnClickListener class on Android var javaObject = NativeObjectUtils.getClass("android/view/View$OnClickListener") // get UIView class on iOS var nsObject = NativeObjectUtils.getClass("UIView")
See also NativeObject::getClass().
NativeObject getContext() |
Returns a NativeObject instance representing the current Android Context.
This method only exists on the Android platform. You can use the Qt global object to find out the currently running platform at runtime:
if(Qt.platform.os === "android") { var context = NativeObjectUtils.getContext() }
You can also use this property from within your NativeView::androidBinding implementation.
See also getActivity() and getService().
NativeObject getService() |
Returns a NativeObject instance representing the current Android Service. If this method is called from an app without a Service, it will return null.
This method only exists on the Android platform. You can use the Qt global object to find out the currently running platform at runtime:
if(Qt.platform.os === "android") { var service = NativeObjectUtils.getService() }
You can also use this property from within your NativeView::androidBinding implementation.
See also getContext() and getService().
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: