0

Why my pdf file is not working or displayed when I run it? I included the pdf file in my asset folder but still it not working. why is it so? is there any limitation for adding pdf to the asset folder. I am developing an app which will contain more than 20 pdf. currently, I have included 25 pdf in my asset folder. other pdf's are working but only following activity pdf is not working why is it so?

This is PDFCE4Activity.java
```package com.example.easylearn;

 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.appcompat.app.AppCompatActivity;

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.ListView;
  import android.widget.TextView;

 import com.github.barteksc.pdfviewer.PDFView;
 import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
 import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
  import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
   import com.shockwave.pdfium.PdfDocument;
 import com.google.firebase.auth.FirebaseAuth;

     import java.util.List;
     public class PDFCE4Activity extends AppCompatActivity {

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

    pdflistview = (ListView) findViewById(R.id.myPDFlist4);
    String[] easylearn  = {"High Performance Computing","Artificial Intelligence","Digital Signal 
    Processing"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String> 
    (this,android.R.layout.simple_list_item_1,easylearn){
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){
            View view = super.getView(position,convertView,parent);
            TextView myText = (TextView) view.findViewById(android.R.id.text1);
            return view;
        }
    };

    pdflistview.setAdapter(adapter);
    pdflistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String item = pdflistview.getItemAtPosition(i).toString();

            Intent start = new Intent(getApplicationContext(),PDFCE3Opener.class);
            start.putExtra("pdfFileName",item);
            startActivity(start);
        }
        });
        }
        }```

     This is my PDFCE4Opener.xml
     ```package com.example.easylearn;

      import androidx.appcompat.app.AppCompatActivity;

      import android.os.Bundle;

      import com.github.barteksc.pdfviewer.PDFView;

       public class PDFCE4Opener extends AppCompatActivity {

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

     myPDFViewer3 = (PDFView) findViewById(R.id.pdfViewer3);
     String getItem = getIntent().getStringExtra("pdfFileName");

      if(getItem.equals("High Performance Computing")){
        myPDFViewer3.fromAsset("High Performance Computing.pdf").load();
    }

    if(getItem.equals("Artificial Intelligence")){
        myPDFViewer3.fromAsset("artificial-intelligence-by-rich-and-knight.pdf").load();
    }

    if(getItem.equals("Digital Signal Processing")){
        myPDFViewer3.fromAsset("Digital Signal Processing.pdf").load();
    }
  }
 }```    

 This is my activity_pdfce4.xml
 ```<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
tools:context=".PDFCE4Activity">

  <ListView
    android:id="@+id/myPDFlist4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp">

  </ListView>
 </RelativeLayout>```

 This is my activity_pdfce4_opener.xml
 ``` <?xml version="1.0" encoding="utf-8"?>
     <androidx.constraintlayout.widget.ConstraintLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
       tools:context=".PDFCE4Opener">

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

      </androidx.constraintlayout.widget.ConstraintLayout>```

0 Answers0