File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
tutorials/platform/android Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -133,3 +133,28 @@ This example creates an intent to send a text:
133133 intent.putExtra(Intent.EXTRA_TEXT, "This is a test message.")
134134 intent.setType("text/plain")
135135 activity.startActivity(intent)
136+
137+ Example: Saving an image to the Android gallery
138+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
140+ .. code-block :: gdscript
141+
142+ # Retrieve the AndroidRuntime singleton.
143+ var android_runtime = Engine.get_singleton("AndroidRuntime")
144+ if android_runtime:
145+ var Intent = JavaClassWrapper.wrap("android.content.Intent")
146+ var activity = android_runtime.getActivity()
147+ var intent = Intent.Intent()
148+
149+ # Create the File and Uri.
150+ var Uri = JavaClassWrapper.wrap("android.net.Uri")
151+ var File = JavaClassWrapper.wrap("java.io.File")
152+ var file = File.File(file_path_to_image_here)
153+ var uri = Uri.fromFile(file)
154+
155+ # Set Action and Data of Intent.
156+ intent.setAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
157+ intent.setData(uri)
158+
159+ # Broadcast it.
160+ activity.sendBroadcast(intent)
You can’t perform that action at this time.
0 commit comments