I'm stuck (and therefore missing something obvious).
My app saves its content to XML files and I'm working on the functionality to share a saved file and to open a file shared by someone else. I'd like the "open from someone else" functionality to use Activity.StartingIntent to respond to VIEW, EDIT or SEND xml mime types (the App should be recognised as an XML filetype handler).
After reading multiple posts from those who've gone before (thanks!) I have the following in Manifest Editor:
And I have the following in Activity_Resume for the Main activity:
Sending myself an xml file attached to an email, opening the email on my device and clicking the attachment, I see my app in the list and I chose to "just once" open the xml file with my app.
I get the following in the log:
But then I'm stuck. How do I open the XML file using the content:// uri?
My app saves its content to XML files and I'm working on the functionality to share a saved file and to open a file shared by someone else. I'd like the "open from someone else" functionality to use Activity.StartingIntent to respond to VIEW, EDIT or SEND xml mime types (the App should be recognised as an XML filetype handler).
After reading multiple posts from those who've gone before (thanks!) I have the following in Manifest Editor:
B4X:
AddActivityText(Main,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/xml" />
<data android:mimeType="application/xml" />
</intent-filter>)
And I have the following in Activity_Resume for the Main activity:
B4X:
Sub Activity_Resume
Dim StartingIntent As Intent = Activity.GetStartingIntent
Log(StartingIntent)
If IsRelevantIntent(StartingIntent) Then
Select StartingIntent.Action
Case StartingIntent.ACTION_VIEW
Dim sURI As String = StartingIntent.GetData
Log(sURI)
Case StartingIntent.ACTION_EDIT
Case StartingIntent.ACTION_SEND
End Select
Else
UpdateDisplay
End If
End Sub
Private Sub IsRelevantIntent(in As Intent) As Boolean
If in.IsInitialized And in <> oldIntent Then
If in.Action = in.ACTION_VIEW Or in.Action = in.ACTION_EDIT Or in.Action = in.ACTION_SEND Then
oldIntent = in
Return True
End If
End If
Return False
End Sub
Sending myself an xml file attached to an email, opening the email on my device and clicking the attachment, I see my app in the list and I chose to "just once" open the xml file with my app.
I get the following in the log:
B4X:
(Intent) Intent { act=android.intent.action.VIEW dat=content://com.google.android.gm.email.attachmentprovider/3/4920/RAW typ=text/xml flg=0x13080001 cmp=scb.misterbates.intervalsplus.dev/.main }
content://com.google.android.gm.email.attachmentprovider/3/4920/RAW
But then I'm stuck. How do I open the XML file using the content:// uri?