Android Question Error When Opennig File

alon

Active Member
Licensed User
Longtime User
Hi ,

I am trying to open files from my app, and while trying to do so
I am getting the following Error:

(Exception) java.lang.Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/Bina.AhzakaMelech/files/tmpFileBinyan.jpg typ=application/jpg flg=0x20000 }

The only file that I can open is PDF,
and by the way when I am trying to open the file outside my app, there is no problem.

Here Is My Code:
B4X:
Sub lblHatsegKovez_Click()
   
    Dim lbl As Label = Sender
    lbl.Enabled = False
   
    Dim cRec As Cursor
    cRec = DBUtils.FnOpenRecSet(Starter.sql,"select * from AttachedFiles WHERE recid = " & lbl.Tag)
    If cRec.RowCount > 0 Then
        cRec.Position = 0
       
       
        Try
           
            Dim su As StringUtils
            Dim b() As Byte = su.DecodeBase64(cRec.GetString("File64"))
            Dim dir As String = File.DirDefaultExternal
   
       
            Dim out As OutputStream =File.OpenOutput(dir,  "tmpFileBinyan." & cRec.GetString("FileType")  , False)
            out.WriteBytes(b, 0, b.Length)
            out.Close
'           
           
            Dim i As Intent
            i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(dir & "/",  "tmpFileBinyan." & cRec.GetString("FileType")))
            i.SetType("application/" &  cRec.GetString("FileType")  )

           
            StartActivity(i)
        Catch
            Log(LastException)
        End Try
    End If
   
    lbl.Enabled = True
   
   
End Sub


Thanks you all...
 

alon

Active Member
Licensed User
Longtime User
I think the problem is with the SetType,
Where Can I find a list with alltypes.

Thanks
 
Upvote 0
Top