Android Question Use Intent to open a Text Log File

lip

Active Member
Licensed User
Longtime User
Hopefully a simple one:

I am writing a log file (log.txt) into File.DirDefaultExternal

I can use File Viewer to see the file. It opens on my Tablet in Polaris Office.

I am now trying to make a Button to open the file. Ideally This should not specifically use Polaris as other users will have different text file viewers.

I have been trying to use Intent with .Initialize2(File.DirDefaultExternal & "/log.txt") without success. Is this the right approach?
 

lip

Active Member
Licensed User
Longtime User
Try this:
B4X:
myFile = File.Combine(File.DirDefaultExternal, "Log.txt")
 
Dim i As Intent
 
i.Initialize(i.ACTION_VIEW, myFile)
i.SetType("text/plain")
 
StartActivity(i)

Thanks - this looks logical, but when I tried it (only change was Dim myFile as String at the top) I get a message "Not a supported Document Type"
 
Upvote 0
Top