Does Pdfview have reserved words?

Asked

Viewed 24 times

0

I am using the Pdfview library to open a pdf of my xampp but it does not open anything, this is the code I am trying:

Readpdfstream.java

package com.app.read_basic_pdf;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.github.barteksc.pdfviewer.PDFView;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;


public class ReadPDFStream extends AppCompatActivity {

PDFView pdfView;

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pdfstream);

    pdfView = findViewById(R.id.pdfView);
        new 
 RetrievePDFStream().execute("http://192.168.0.22/projetos/pdf/sample.pdf" );     }


    class RetrievePDFStream extends AsyncTask<String,Void,InputStream>
    {

        @Override
        protected InputStream doInBackground(String... strings)
        {
            InputStream inputStream = null;

            try{
                URL url = new URL(strings[0]);
                HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
                if(urlConnection.getResponseCode() == 50)

                {
                    inputStream = new BufferedInputStream(urlConnection.getInputStream());
                }

            }
            catch (IOException e)
            {
                return null;
            }
            return inputStream;
        }
        @Override
        protected void onPostExecute(InputStream inputStream){
            //super.onPostExecute(inputStream);
            pdfView.fromStream(inputStream).load();

        }

    }

} // fim ::

activity_pdfstream.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_pdfstream"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBotton="16dp"
android:paddingTop="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
tools:context=".ReadPDFStream">

<com.github.barteksc.pdfviewer.PDFView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
android:id="@+id/pdfView"


    />

  • 05-01 20:44:39.271 15407-15407/? E/zygote: Mountemulatedstorage() 05-01 20:44:39.271 15407-15407/? E/Zygote: v2 05-01 20:44:39.271 15407-15407/? E/Selinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL

  • editei a variável que levava o mesmo nome do componente e funcionou: &#xA; PDFView pdfView; para PDFView pdfV;&#xA;...&#xA;pdfV = findViewById(R.id.pdfView);

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.