lundi 29 juin 2015

How to open a local PDF in android?


I need to show a local pdf in my android app, this pdf needs to be included in my app package, I have this but I dont know how to build a File class.

public void loadreglamento(View v){
        //Im supposed to give a path with the file but I really dont know how
        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(path, "application/pdf");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

    }

This code is Ok for me, I dont care If the user see the document in an external viewer/editor.

I also need to know where I have to copy the PDF file.

Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire