Hi All,
I am trying to find a way to save email attachments into a specific folder, which I can then access from inside my app. This would be used to import a data (.txt) file into the app from an email, allowing datasets to be shared between users, without worrying about a live sync system. I have figured out what I believe to be half of the solution, using intents to capture the 'view' event upon trying to view the attachment. However, I cannot figure out how to go from that point to either saving the attachment directly or loading the content of the attachment into my app, so that I can write it to a .txt file.
I have added the following into the manifest editor:
and this successfully displays my app in the 'Complete action using...' menu that appears when I try to view a .txt attachment. I have also added in the activity class, and have been able to call the starting intent, as below:
However, this is where I am getting stuck. How do I go from capturing the intent to saving the file? Do I need to use the uriString from the first intent to somehow call another, or is there something that I am missing? I have tried a few things, and trawled through the forums trying to find an answer, but haven't stumbled across anything as yet.
Any help on this would be greatly appreciated!
Cheers, Ben.
I am trying to find a way to save email attachments into a specific folder, which I can then access from inside my app. This would be used to import a data (.txt) file into the app from an email, allowing datasets to be shared between users, without worrying about a live sync system. I have figured out what I believe to be half of the solution, using intents to capture the 'view' event upon trying to view the attachment. However, I cannot figure out how to go from that point to either saving the attachment directly or loading the content of the attachment into my app, so that I can write it to a .txt file.
I have added the following into the manifest editor:
B4X:
AddActivityText(ImportIntent,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>)
and this successfully displays my app in the 'Complete action using...' menu that appears when I try to view a .txt attachment. I have also added in the activity class, and have been able to call the starting intent, as below:
B4X:
Sub Globals
Dim TextInput As Intent
End Sub
Sub Activity_Create(FirstTime As Boolean)
TextInput = Activity.GetStartingIntent
End Sub
However, this is where I am getting stuck. How do I go from capturing the intent to saving the file? Do I need to use the uriString from the first intent to somehow call another, or is there something that I am missing? I have tried a few things, and trawled through the forums trying to find an answer, but haven't stumbled across anything as yet.
Any help on this would be greatly appreciated!
Cheers, Ben.