Android Question How to Open File from External application using Intent

junaidahmed

Well-Known Member
Licensed User
Longtime User
I am using "Intent" to open Image File in my application.I have four external application to open Image.My question is when I open File from Intent ,it should show list of external application...

B4X:
Sub ViewFiles(StrPath As String)

    Dim Ext As String
    Dim i As Intent 'Requires a reference to the Phone library
    
        
    i.Initialize(i.ACTION_VIEW,StrPath.Trim)
    Ext = StrFileName.SubString(StrFileName.Length-3)
            
    Select Case Ext.ToUpperCase
        Case "JPG"
            i.SetType("image/*")
        Case "PNG"
            i.SetType("image/*")
        Case "PDF"
            i.SetType("application/pdf")   
        Case "XLS"
            i.SetType("application/vnd.ms-excel")
        Case "XLSX"
            i.SetType("application/vnd.ms-excel")
        Case "TXT"
            i.SetType("text/plain")
        Case "DOC"
            i.SetType("application/msword")
        Case "DOCX"
            i.SetType("application/msword")
        Case "PPT"
            i.SetType("application/vnd.ms-powerpoint")
        Case "PPTX"
            i.SetType("application/vnd.ms-powerpoint")
    End Select
    StartActivity(i)
        
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
it should show list of external application
i guess you have defined a Default already.... Answered to use the selected app as default.

Remove the Default from the Android Setting and try again.
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
Actually When I Open from "EsFile Explorer",then Its showing all External application,but When I run from above code its not showing .....
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
is the path accessible from other apps?
DOCX,XLSX,PPTX did not work , you cut 3 chars here
B4X:
.SubString(StrFileName.Length-3)
better split by dot starting from right side of filename.
 
Upvote 0
Top