File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
tutorials/platform/android Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -113,3 +113,23 @@ Java inner classes can be accessed using the ``$`` sign:
113
113
# Do something specific on android 11 devices.
114
114
else:
115
115
# All other devices
116
+
117
+ Example: Calling a constructor
118
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
+
120
+ A constructor is invoked by calling a method with the same name as the class.
121
+
122
+ This example creates an intent to send a text:
123
+
124
+ .. code-block :: gdscript
125
+
126
+ # Retrieve the AndroidRuntime singleton.
127
+ var android_runtime = Engine.get_singleton("AndroidRuntime")
128
+ if android_runtime:
129
+ var Intent = JavaClassWrapper.wrap("android.content.Intent")
130
+ var activity = android_runtime.getActivity()
131
+ var intent = Intent.Intent() # Call the constructor.
132
+ intent.setAction(Intent.ACTION_SEND)
133
+ intent.putExtra(Intent.EXTRA_TEXT, "This is a test message.")
134
+ intent.setType("text/plain")
135
+ activity.startActivity(intent)
You can’t perform that action at this time.
0 commit comments