12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <class name="JavaClassWrapper" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
- <brief_description>
- Provides access to the Java Native Interface.
- </brief_description>
- <description>
- The JavaClassWrapper singleton provides a way for the Godot application to send and receive data through the [url=https://developer.android.com/training/articles/perf-jni]Java Native Interface[/url] (JNI).
- [b]Note:[/b] This singleton is only available in Android builds.
- [codeblock]
- var LocalDateTime = JavaClassWrapper.wrap("java.time.LocalDateTime")
- var DateTimeFormatter = JavaClassWrapper.wrap("java.time.format.DateTimeFormatter")
- var datetime = LocalDateTime.now()
- var formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss")
- print(datetime.format(formatter))
- [/codeblock]
- [b]Warning:[/b] When calling Java methods, be sure to check [method JavaClassWrapper.get_exception] to check if the method threw an exception.
- </description>
- <tutorials>
- </tutorials>
- <methods>
- <method name="get_exception">
- <return type="JavaObject" />
- <description>
- Returns the Java exception from the last call into a Java class. If there was no exception, it will return [code]null[/code].
- [b]Note:[/b] This method only works on Android. On every other platform, this method will always return [code]null[/code].
- </description>
- </method>
- <method name="wrap">
- <return type="JavaClass" />
- <param index="0" name="name" type="String" />
- <description>
- Wraps a class defined in Java, and returns it as a [JavaClass] [Object] type that Godot can interact with.
- When wrapping inner (nested) classes, use [code]$[/code] instead of [code].[/code] to separate them. For example, [code]JavaClassWrapper.wrap("android.view.WindowManager$LayoutParams")[/code] wraps the [b]WindowManager.LayoutParams[/b] class.
- [b]Note:[/b] This method only works on Android. On every other platform, this method does nothing and returns an empty [JavaClass].
- </description>
- </method>
- </methods>
- </class>
|