Sub Process_Globals
End Sub
Sub Globals
Private TestPath As String
Private Label1 As Label
Private btn2ViewImage As Button
Private RP As RuntimePermissions
End Sub
Sub Activity_Create(FirstTime As Boolean)
RP.CheckAndRequest(RP.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'Don't miss the code in the manifest editor!!!
Activity.LoadLayout("1")
TestPath = File.DirRootExternal & "/documents"
Label1.Text = "TestPath = " & TestPath
End Sub
Sub btnShareFile_Click
Dim FileToSend As String = "Message.txt"
File.WriteString(Starter.Provider.SharedFolder, FileToSend, "jaklsdjalksdjalskdjasld")
Dim in As Intent
in.Initialize(in.ACTION_SEND, "")
in.SetType("text/plain")
in.PutExtra("android.intent.extra.STREAM", Starter.Provider.GetFileUri(FileToSend))
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
End Sub
Sub btnViewImage_Click
Dim FileName As String = "b4a.png"
File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "")
Starter.Provider.SetFileUriAsIntentData(in, FileName)
'Type must be set after calling SetFileUriAsIntentData
in.SetType("image/*")
StartActivity(in)
End Sub
Sub btnSendEmail_Click
Dim FileName As String = "b4a.png"
'copy the shared file to the shared folder
File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
Dim email As Email
email.To.Add("aaa@bbb.com")
email.Subject = "subject"
email.Attachments.Add(Starter.Provider.GetFileUri(FileName))
email.Attachments.Add(Starter.Provider.GetFileUri(FileName)) 'second attachment
Dim in As Intent = email.GetIntent
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn2ViewImage_Click
Try
Dim FileName As String = "red.png"
File.Copy(TestPath, FileName, Starter.Provider.SharedFolder, FileName)
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "")
Starter.Provider.SetFileUriAsIntentData(in, FileName)
'Type must be set after calling SetFileUriAsIntentData
in.SetType("image/*")
StartActivity(in)
Catch
Msgbox(LastException.Message,"")
End Try
End Sub