Mar 18, 2015 Replies: 42 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). 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 Code: Copy 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 Click to expand...
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). 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 Code: Copy 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
N n3t Member Licensed User Longtime User Jul 1, 2015 #21 Erel said: @n3t have you copied the xml file to internal libraries folder? @tucano2000 in most cases it works properly without setting the type. Have you tried it? Click to expand... Yes the lib is ok. Tested on iPhone and iPad. Same problem. Seems that the returned value is not a Boolean (may be a Int?)
Erel said: @n3t have you copied the xml file to internal libraries folder? @tucano2000 in most cases it works properly without setting the type. Have you tried it? Click to expand... Yes the lib is ok. Tested on iPhone and iPad. Same problem. Seems that the returned value is not a Boolean (may be a Int?)
Erel B4X founder Staff member Licensed User Longtime User Jul 1, 2015 #22 tucano2000 said: I already tried without using the type but still shows a dialog and the list of applications Click to expand... It always shows the dialog with all apps that can open this file.
tucano2000 said: I already tried without using the type but still shows a dialog and the list of applications Click to expand... It always shows the dialog with all apps that can open this file.
Erel B4X founder Staff member Licensed User Longtime User Jul 1, 2015 #23 n3t said: Seems that the returned value is not a Boolean (may be a Int?) Click to expand... V2.0 beta will be soon released. Please try it again with the beta version. If it doesn't work then you should post the code.
n3t said: Seems that the returned value is not a Boolean (may be a Int?) Click to expand... V2.0 beta will be soon released. Please try it again with the beta version. If it doesn't work then you should post the code.
N n3t Member Licensed User Longtime User Jul 1, 2015 #24 Erel said: V2.0 beta will be soon released. Please try it again with the beta version. If it doesn't work then you should post the code. Click to expand... Tested with last beta. It's OK. thanks Last edited: Jul 2, 2015
Erel said: V2.0 beta will be soon released. Please try it again with the beta version. If it doesn't work then you should post the code. Click to expand... Tested with last beta. It's OK. thanks
mrossen Active Member Licensed User Longtime User Sep 5, 2015 #25 Hi, Is it possible to change the language in the window. The text for the apps and "Cancel" is always in English. I would like to change this to my phones default language. (Danish) Mogens
Hi, Is it possible to change the language in the window. The text for the apps and "Cancel" is always in English. I would like to change this to my phones default language. (Danish) Mogens
Erel B4X founder Staff member Licensed User Longtime User Sep 6, 2015 #26 Is your device locale set to Danish?
mrossen Active Member Licensed User Longtime User Sep 6, 2015 #27 I haven't changes anything in settings since installation of ios9. Anything else on the iPhone is on Danish. When I look in settings/Language & Area it says Danish Mogens
I haven't changes anything in settings since installation of ios9. Anything else on the iPhone is on Danish. When I look in settings/Language & Area it says Danish Mogens
Erel B4X founder Staff member Licensed User Longtime User Sep 6, 2015 #28 Based on the documentation it should use the device locale. There is no other API to change the button text.
Based on the documentation it should use the device locale. There is no other API to change the button text.
JackKirk Well-Known Member Licensed User Longtime User Aug 22, 2017 #29 I have semi-successfully got DocumentInteraction working in my app. I say "semi" because I want to share jpgs to the same range of apps as you can from the photos app. For example, sharing from the photos app I can share to Messages(SMS) and Mail(email) but I can not share to these from my app. I've googled up on UTIs and tried all that seem even remotely relevant - all to no avail. Anyone have any insight?
I have semi-successfully got DocumentInteraction working in my app. I say "semi" because I want to share jpgs to the same range of apps as you can from the photos app. For example, sharing from the photos app I can share to Messages(SMS) and Mail(email) but I can not share to these from my app. I've googled up on UTIs and tried all that seem even remotely relevant - all to no avail. Anyone have any insight?
Erel B4X founder Staff member Licensed User Longtime User Aug 22, 2017 #30 If you want to share a photo: https://www.b4x.com/android/forum/t...pp-with-activityviewcontroller.73159/#content
If you want to share a photo: https://www.b4x.com/android/forum/t...pp-with-activityviewcontroller.73159/#content
JackKirk Well-Known Member Licensed User Longtime User Aug 23, 2017 #31 Erel said: If you want to share a photo: https://www.b4x.com/android/forum/t...pp-with-activityviewcontroller.73159/#content Click to expand... Thanks Erel, Problem is, with ActivityViewController I can share to: Message, Mail and Facebook With DocumentInteraction I can share to: iCloud, Instagram, Facebook and Twitter. And there does not appear to be a way to augment either - any hints? Thanks...
Erel said: If you want to share a photo: https://www.b4x.com/android/forum/t...pp-with-activityviewcontroller.73159/#content Click to expand... Thanks Erel, Problem is, with ActivityViewController I can share to: Message, Mail and Facebook With DocumentInteraction I can share to: iCloud, Instagram, Facebook and Twitter. And there does not appear to be a way to augment either - any hints? Thanks...
JackKirk Well-Known Member Licensed User Longtime User Aug 23, 2017 #33 Erel, you can stop worrying again The solution is so stupidly simple - I'm not sure what this says about me. Code: Copy UI_activityviewcontroller.Initialize("Event_UI_activityviewcontroller", Array(wrk_bmp)) UI_activityviewcontroller.Show(Showlist_page, Showlist_page.RootPanel) NOT: Code: Copy UI_activityviewcontroller.Initialize("Event_UI_activityviewcontroller", Array("text message", wrk_bmp)) UI_activityviewcontroller.Show(Showlist_page, Showlist_page.RootPanel) Instagram only accepts images (apparently) so if you dispense with the "text message", I get the identical popup as when I share an image from the Photos app. Happy days...
Erel, you can stop worrying again The solution is so stupidly simple - I'm not sure what this says about me. Code: Copy UI_activityviewcontroller.Initialize("Event_UI_activityviewcontroller", Array(wrk_bmp)) UI_activityviewcontroller.Show(Showlist_page, Showlist_page.RootPanel) NOT: Code: Copy UI_activityviewcontroller.Initialize("Event_UI_activityviewcontroller", Array("text message", wrk_bmp)) UI_activityviewcontroller.Show(Showlist_page, Showlist_page.RootPanel) Instagram only accepts images (apparently) so if you dispense with the "text message", I get the identical popup as when I share an image from the Photos app. Happy days...
tcgoh Active Member Licensed User Longtime User Oct 7, 2017 #34 Hi, Can I open an external CSV file stored in dropbox with my own APP created by B4i using this lib? Thanks
Hi, Can I open an external CSV file stored in dropbox with my own APP created by B4i using this lib? Thanks
Erel B4X founder Staff member Licensed User Longtime User Oct 8, 2017 #35 Follow this tutorial: https://www.b4x.com/android/forum/threads/open-external-files-with-your-app.50525/#content
Follow this tutorial: https://www.b4x.com/android/forum/threads/open-external-files-with-your-app.50525/#content
Star-Dust Expert Licensed User Longtime User Aug 5, 2021 #36 Hello everyone, I put this code inside B4XPages and I get this error B4X: Copy Sub Class_Globals Private di As DocumentInteraction End Sub Public Sub VievFile(Path As String, FileName As String) di.Initialize("di", Path, FileName) di.OpenFile(B4XPages.GetNativeParent(B4XPages.MainPage).RootPanel) End Sub Warning: Attempt to present <_UIDICActivityViewController: 0x10182bc00> on Page (vc): Azienda Digitale whose view is not in the window hierarchy! Click to expand...
Hello everyone, I put this code inside B4XPages and I get this error B4X: Copy Sub Class_Globals Private di As DocumentInteraction End Sub Public Sub VievFile(Path As String, FileName As String) di.Initialize("di", Path, FileName) di.OpenFile(B4XPages.GetNativeParent(B4XPages.MainPage).RootPanel) End Sub Warning: Attempt to present <_UIDICActivityViewController: 0x10182bc00> on Page (vc): Azienda Digitale whose view is not in the window hierarchy! Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Aug 6, 2021 #37 Are you sure that the main page is the visible page when this code runs?
Star-Dust Expert Licensed User Longtime User Aug 6, 2021 #38 I honestly don't know exactly how to answer this question. It is a B4XPages App that works in the foreground. When I call this code I am in a B4XPages page, I guess I should consider the Main Page visible because I see the B4XPage
I honestly don't know exactly how to answer this question. It is a B4XPages App that works in the foreground. When I call this code I am in a B4XPages page, I guess I should consider the Main Page visible because I see the B4XPage
Star-Dust Expert Licensed User Longtime User Aug 6, 2021 #40 Erel said: Are there multiple pages? Click to expand... Yes, is the third inside page