File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
tutorials/platform/android Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -133,3 +133,27 @@ 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: Using an Intent to Save an Image to an Android Gallery
138+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
140+ .. code-block :: gdscript
141+ # Retrieve the AndroidRuntime singleton.
142+ var android_runtime = Engine.get_singleton("AndroidRuntime")
143+ if android_runtime:
144+ var Intent = JavaClassWrapper.wrap("android.content.Intent")
145+ var Uri = JavaClassWrapper.wrap("android.net.Uri")
146+ var File = JavaClassWrapper.wrap("java.io.File")
147+
148+ # Create the File and Uri
149+ var file = File.File(file_path_to_image_here)
150+ var uri = Uri.fromFile(file)
151+
152+ # Build the Intent
153+ var intent = Intent.Intent()
154+ intent.setAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
155+ intent.setData(uri)
156+
157+ # Broadcast it
158+ var activity = android_runtime.getActivity()
159+ activity.sendBroadcast(intent)
You can’t perform that action at this time.
0 commit comments