tdocs2 Well-Known Member Licensed User Longtime User Mar 9, 2013 #1 Greetings and thank you in advance for answering my question. Is there a way from B4A code to give Android OS a filename, e.g., file1.csv, to start an app in the device that can handle this type of file? In the case of a csv file, if the device had Kingston Office, Documents to Go, or Quickoffice, any of these apps would be started and display a spreadsheet format. I am familiar and have experimented with the phone.PackageManager (pm) and its features to "shell" to an external app. For example, I have started The Kingston Office as well as other apps by using its package name with pm.GetApplicationIntent. I do not know how to "pass" a filename as an extra to any of the apps referenced above. I have looked in the B4A forum and have not found an answer. Any and all help will be welcomed.
Greetings and thank you in advance for answering my question. Is there a way from B4A code to give Android OS a filename, e.g., file1.csv, to start an app in the device that can handle this type of file? In the case of a csv file, if the device had Kingston Office, Documents to Go, or Quickoffice, any of these apps would be started and display a spreadsheet format. I am familiar and have experimented with the phone.PackageManager (pm) and its features to "shell" to an external app. For example, I have started The Kingston Office as well as other apps by using its package name with pm.GetApplicationIntent. I do not know how to "pass" a filename as an extra to any of the apps referenced above. I have looked in the B4A forum and have not found an answer. Any and all help will be welcomed.
Erel B4X founder Staff member Licensed User Longtime User Mar 9, 2013 #2 You should send an intent with the file and set the data type: Code: Copy Try Dim i As Intent i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "1.csv")) i.SetType("text/csv") StartActivity(i) Catch ToastMessageShow("No matching application.", True) Log(LastException) End Try Upvote 0
You should send an intent with the file and set the data type: Code: Copy Try Dim i As Intent i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "1.csv")) i.SetType("text/csv") StartActivity(i) Catch ToastMessageShow("No matching application.", True) Log(LastException) End Try
tdocs2 Well-Known Member Licensed User Longtime User Mar 9, 2013 #3 Using file name to shell to app Thank you, Erel. It works perfectly. I tried it on my S3 where it gave a choice since 2 apps could handle the intent and on a Visual Land Prestige 10 where it shelled directly to the app that opened the CSV. Simplicity itself! The amazing power and versatility of B4A. I hope others can benefit from this thread. Best regards. Sandy Upvote 0
Using file name to shell to app Thank you, Erel. It works perfectly. I tried it on my S3 where it gave a choice since 2 apps could handle the intent and on a Visual Land Prestige 10 where it shelled directly to the app that opened the CSV. Simplicity itself! The amazing power and versatility of B4A. I hope others can benefit from this thread. Best regards. Sandy