My app shows a list of file names.
Clicking on a file name shows the file, offering the suitable app (Open With)
The code for doing this (as shown by Erel) is:
It works fine.
pictures (.jpg .gif ) are offered Gallery (and more apps)
texts (.txt .log) are offered a choice of text editors
web pages (.html) are offered a chice of browsers (and text editors)
.pdf are offered PDF viewers
and so on with "well established" extensions
The problem is with "unregistered" extension.
I have files with strange extensions (some are created by me) like .hst .rec .123 .xyz etc...
Since there is no app associated with them, another app is invoked (in my case some game installed)
My question is:
Is there a way to determine if there is NO app associated with that extension, so I ignore the "file intent".
It is possible to store all "known" extensions in the prog - BUT this does not cater for an "new" extension associated with an app.
Clicking on a file name shows the file, offering the suitable app (Open With)
The code for doing this (as shown by Erel) is:
B4X:
Sub File_Intent(Dir As String,Fn As String)
File.Copy(Dir, Fn, shared, Fn)
Dim in As Intent
in.Initialize(in.ACTION_VIEW, CreateFileProviderUri(shared, Fn))
in.Flags = 1
StartActivity(in)
End Sub
Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(Dir, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub
It works fine.
pictures (.jpg .gif ) are offered Gallery (and more apps)
texts (.txt .log) are offered a choice of text editors
web pages (.html) are offered a chice of browsers (and text editors)
.pdf are offered PDF viewers
and so on with "well established" extensions
The problem is with "unregistered" extension.
I have files with strange extensions (some are created by me) like .hst .rec .123 .xyz etc...
Since there is no app associated with them, another app is invoked (in my case some game installed)
My question is:
Is there a way to determine if there is NO app associated with that extension, so I ignore the "file intent".
It is possible to store all "known" extensions in the prog - BUT this does not cater for an "new" extension associated with an app.