iOS Tutorial Open local files with external apps

iPhone library v1.40 includes a new object type named DocumentInteraction.

With this controller you can allow the user to open a local file with an external app (this is the other side of this tutorial: https://www.b4x.com/android/forum/threads/open-external-files-with-your-app.50525/#content).

SS-2015-03-18_09.27.24.png


Using DocumentInteraction is pretty simple. You initialize it with the file that you want to open and then call DocumentInteraction.OpenFile.

You can optionally set the file type with the UTI property. The system types are listed here: https://developer.apple.com/library...fiers.html#//apple_ref/doc/uid/TP40009259-SW1

B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private di As DocumentInteraction
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.Color = Colors.Green
   NavControl.ShowPage(Page1)
   di.Initialize("di", File.DirAssets, "Workbook.xls") '<--- open a file from the assets folder
End Sub

Sub Page1_Click
   di.OpenFile(Page1.RootPanel)
End Sub

Sub di_Closed
   Log("Dialog closed")
End Sub

Sub di_SendingFile
   Log("Opening file")
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Try this:
B4X:
di.OpenFile(B4XPages.GetNativeParent(B4XPages.GetManager.GetTopPage.B4XPage).RootPanel)
Ok. I'll try It. Thank's
 

Star-Dust

Expert
Licensed User
Longtime User
Try this:
B4X:
di.OpenFile(B4XPages.GetNativeParent(B4XPages.GetManager.GetTopPage.B4XPage).RootPanel)
Thanks, that's how it works
 
Top