0

I put some pdf files to test pdf loading from external storage and made a code following :

enter image description here

The code is :

val main_path = "/storage/emulated/0/"
val dl_path = Environment.DIRECTORY_DOWNLOADS
val filename = "GLCIC.pdf"
val filename2 = "edge.pdf"
private val img_path = Environment.DIRECTORY_DCIM
private val mv_path = Environment.DIRECTORY_MOVIES

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    if(checkPermission(Storage_Permission,Flag_Permission_storage)){
        Log.d("check","Permission Granted")
    }


    val intent = Intent(this,ViewActivity::class.java)
    val intent_store = Intent(this,ViewActivity::class.java)
    btn1.setOnClickListener {
        intent.putExtra("pressed","asset")
        startActivity(intent) }

    btn2.setOnClickListener {
        intent_store.putExtra("pdf",main_path+dl_path+"/"+filename2)
        startActivity(intent_store)

This is a code in mainActivity and pressing btn2 will pass an Intent to viewActivity.

val pressed2 = intent.getStringExtra("pdf")
    Log.d("1","112:"+pressed2.toString())
    if(!TextUtils.isEmpty(pressed2))
    {
        Log.d("1","11:"+pressed2.toString())
        val pdf_file = File(pressed2)
        pdfview.fromFile(pdf_file)
    }

This is code in viewActivity.

This code made a log :

D/1: 112:/storage/emulated/0/Download/edge.pdf
11:/storage/emulated/0/Download/edge.pdf

Judging from the log I don't think that I made any mistake, but the pdfview did not work, showing the white screen .

Please somebody tell me where I made mistake. I really want to load a file, or make a list of files in a directory. But I am mazed for few weeks.

4
  • How did you put those files in Download folder? Commented Nov 5, 2020 at 9:24
  • Please post your code as text. Commented Nov 5, 2020 at 9:44
  • @blackapps Thanks for your help and I added code Commented Nov 5, 2020 at 11:56
  • Please dont post images. Only text. Remove the image. You could also just tell how you placed the images there. Commented Nov 5, 2020 at 11:59

1 Answer 1

0

Maybe the text color is white. Try setting the text color to Black, I made this mistake once and I had set the text color to White by mistake, so maybe it could work.

And if its not the text color then please upload the entire code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.