Android Question error open downloaded PDF file with android 7+

Discussion in 'Android Questions' started by nickysuwandi, Oct 3, 2018.

  1. nickysuwandi

    nickysuwandi Member Licensed User

    Hi all
    i had try this project from this thread ( https://www.b4x.com/android/forum/threads/solve-error-open-pdf-file-with-android-7.97467/ ) to open pdf download from web service, but got error "(NullPointerException) java.lang.NullPointerException:Attempt to invoke virtual method android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,jva.lang.String) on a null object reference"

    Anybody can help me,where wrong to my code:

    Code:
    Sub imgdownload_Click
        
    Dim intresult As Int
        intresult=
    Msgbox2("Download Report ??","Download","Yes","Cancell","",Null )
        
    If intresult=DialogResponse.POSITIVE Then
            
    ProgressDialogShow2("Please wait . . .",  True)
            
    Dim job As HttpJob
            job.Initialize(
    "pdf" , Me)
            
    Dim S As String = Starter.serverAddress & "/report.php?usr=" & Starter.strusr & "&psw=" & Starter.strtoken
            job.Download(s)
            
    wait for (job) JobDone (job As HttpJob)
            
    If job.Success = True Then
                
    Try
                    
    Dim out As OutputStream=File.OpenOutput(Starter.shared ,"report.pdf",  False )
                    
    File.Copy2(job.GetInputStream  ,out)
                    out.Close
                    
                    
    Dim Intent1 As Intent
                    Intent1.Initialize(Intent1.ACTION_VIEW, app.CreateFileProviderUri(Starter.shared, 
    "report.pdf"))
                    Intent1.SetType(
    "application/pdf")
                    Intent1.Flags = 
    1
                    
    Try
                        
    StartActivity(Intent1)
                    
    Catch
                        MsgboxAsync(
    "No App to display PDF files is installed on your device...." & CRLF & CRLF &  LastException,"Error PDF")
                    
    End Try

                
    Catch
                    
    Log(LastException)
                
    End Try
            
    End If
            job.Release
            
    ProgressDialogHide
        
    End If
    End Sub
    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. nickysuwandi

    nickysuwandi Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice