diff --git a/doc/classes/JavaClassWrapper.xml b/doc/classes/JavaClassWrapper.xml index ad99374b9ce..24552e8af33 100644 --- a/doc/classes/JavaClassWrapper.xml +++ b/doc/classes/JavaClassWrapper.xml @@ -18,6 +18,7 @@ [b]Warning:[/b] When calling Java methods, be sure to check [method JavaClassWrapper.get_exception] to check if the method threw an exception. + $DOCS_URL/tutorials/platform/android/javaclasswrapper_and_androidruntimeplugin.html diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt b/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt index 8f0f2bdfb17..35ff7d6fa14 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt @@ -34,51 +34,21 @@ import org.godotengine.godot.Godot import org.godotengine.godot.variant.Callable /** - * Provides access to the Android runtime capabilities. + * Built-in Godot Android plugin used to provide access to the Android runtime capabilities. * - * For example, from gdscript, developers can use [getApplicationContext] to access system services - * and check if the device supports vibration. - * - * var android_runtime = Engine.get_singleton("AndroidRuntime") - * if android_runtime: - * print("Checking if the device supports vibration") - * var vibrator_service = android_runtime.getApplicationContext().getSystemService("vibrator") - * if vibrator_service: - * if vibrator_service.hasVibrator(): - * print("Vibration is supported on device!") - * else: - * printerr("Vibration is not supported on device") - * else: - * printerr("Unable to retrieve the vibrator service") - * else: - * printerr("Couldn't find AndroidRuntime singleton") - * - * - * Or it can be used to display an Android native toast from gdscript - * - * var android_runtime = Engine.get_singleton("AndroidRuntime") - * if android_runtime: - * var activity = android_runtime.getActivity() - * - * var toastCallable = func (): - * var ToastClass = JavaClassWrapper.wrap("android.widget.Toast") - * ToastClass.makeText(activity, "This is a test", ToastClass.LENGTH_LONG).show() - * - * activity.runOnUiThread(android_runtime.createRunnableFromGodotCallable(toastCallable)) - * else: - * printerr("Unable to access android runtime") + * @see Integrating with Android APIs */ class AndroidRuntimePlugin(godot: Godot) : GodotPlugin(godot) { override fun getPluginName() = "AndroidRuntime" /** - * Provides access to the application context to GDScript + * Provides access to the application [android.content.Context] to GDScript */ @UsedByGodot fun getApplicationContext() = activity?.applicationContext /** - * Provides access to the host activity to GDScript + * Provides access to the host [android.app.Activity] to GDScript */ @UsedByGodot override fun getActivity() = super.getActivity()