Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

NativeObjectUtils

NativeObjectUtils allows you to interact with objects native to the mobile platform. More...

Import Statement: import Felgo 3.0
Since: Felgo 3.3.0

Methods

Detailed Description

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.

Method Documentation

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().


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded