schaumermal 0 Posted February 1, 2023 Hello, i have the following question: Can an app based on Delphi serve as a target on the mobile when sharing images or documents, for example? When I use the option "Share", (e.g. in the galary) my app doesn't appear as a target. 1. Is this even possible? 2. If "yes", is there an example of what needs to be done so that the app can receive data? thx Share this post Link to post
programmerdelphi2k 237 Posted February 1, 2023 (edited) first read this: https://developer.android.com/training/sharing/receive This demo shows interaction between Android applications using intents. It consists of two applications, SendIntent that creates and send the intent, and ReceiveIntent that receives the intent and displays the information. https://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.Android_Intents_Sample Edited February 1, 2023 by programmerdelphi2k Share this post Link to post
schaumermal 0 Posted February 2, 2023 Thank you for this hint. I tested it and "hopefully" understood the principle. However, I can't get my app to be displayed as a target if I want to share a photo in the gallery or the document folder on my mobile. I added the following section in the AndroidManifest.template.xml: <intent filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:mimeType="image/*" /> </intent-filter> I thought the entry above controls that my app can receive this type of data but it is not displayed as a target 😞 Share this post Link to post
programmerdelphi2k 237 Posted February 2, 2023 hi @schaumermal I think that the problem here is the "MIME" used to find the apps on Android! really the sample by Embarcadero DONT WORKS for me too! then, I have tested in Embarcadero DEMO project with generic "MIME" = */* and it works! You app will be showed on "choicer"! test in your project: SENDER app: use this: Intent.setType(StringToJString('*/*')); //text/pas RECEIVER app: use this on Android manifest: <data android:mimeType="*/*" /> --> //text/pas--> on intent-filter.... now, all apps that accept your send will be showed on "choicer" https://developer.android.com/reference/androidx/media3/common/MimeTypes https://android.googlesource.com/platform/external/mime-support/+/9817b71a54a2ee8b691c1dfa937c0f9b16b3473c/mime.types Share this post Link to post
schaumermal 0 Posted February 2, 2023 hi @programmerdelphi2k thanks for your previous help. Maybe I didn't express myself correctly. I don't want to send files, i only want to receive files. For example, if I select a file in the gallery or downloads folder and click share, I want my app to appear as a possible destination as well. I see Gmail, Bluetooth, Music, WhatsApp, etc. as possible targets but not my app. Unfortunately, despite your change, my app doesn't show up as a possible destination when I try to share a file from the gallery or from a folder. Share this post Link to post
programmerdelphi2k 237 Posted February 2, 2023 look, your app "just" will be showed if "it" is "identifyed" in your "Android manifest" with the same "MIME" that "other" apps exporting data/info/etc... the Embarcadero sample, works here (but just using MIME = "*/*") --> this a sample!!! not a final app for real-usage! IF YOU DONT WANT a sender-app.. .ok, pay attention only in RECEIVER app! if you app desire receive a file (in a universe of files...), it needs be prepared for this... you needs use "Android manifest" for that, indicating the "MIME" used in "other apps"! for this, you needs knows what is the MIME used by other app! Normally, the "apps" use the MIME known by all ---> see on Android site as above! In rare cases, a MIME (non-default) would can be used... but dont wait for a "blue sky here" Think about this: YOU expect a "cat"!!! SOMEONE send to you a "dog"!!! what do you do? --> accept a "dog" and expect a "MEAWWW" or a "AWW AWW" ? Share this post Link to post
Dave Nottage 557 Posted February 2, 2023 11 hours ago, schaumermal said: I added the following section in the AndroidManifest.template.xml: That doesn't match this pattern: https://developer.android.com/training/sharing/receive#update-manifest I suggest also reading the rest of that page in regards to handling the incoming intent 1 Share this post Link to post
schaumermal 0 Posted February 4, 2023 (edited) Thanks @Dave Nottage, @programmerdelphi2k Now i see my app as a possible target. The next challenge will be to achieve this on IOS. Edited February 4, 2023 by schaumermal Share this post Link to post
Mustafa ֍zgun 7 Posted February 5, 2023 https://github.com/emozgun/delphi-ios-file-storage-sharing Share this post Link to post
barissagir 0 Posted May 7 On 2/4/2023 at 4:35 PM, schaumermal said: Thanks @Dave Nottage, @programmerdelphi2k Now i see my app as a possible target. The next challenge will be to achieve this on IOS. Can you share how you did it? Maybe small app Share this post Link to post