简体   繁体   中英

How to open password protected pdf file by providing password in android application programmatically

I am developing a pdf reader, as android don't have any native pdf viewer so i have to use third party pdf viewer. in that case i have chose the Adobe pdf viewer for android. I can open pdf file which are stored in sdcard of my device. Now i want to open password protected pdf file from my application. If user wants to open password protected pdf file manually then use have to provide password while opening. but i want to open those password pdf file from my application without any password prompt. Application provide the password,[apps knows the password] and without any password prompt, pdf will open.

currently if i want to open any password protected pdf file from my application then a password prompt is appeared and needs a password to open it.

I am using this code to open pdf from my stored pdf files in the /mnt/sdcard/testfolder

Here is the code

protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        PackageManager packageManager = getPackageManager();
        Intent testIntent = new Intent(Intent.ACTION_VIEW);
        testIntent.setType("application/pdf");
        List list = packageManager.queryIntentActivities(testIntent,
                PackageManager.MATCH_DEFAULT_ONLY);
        if (list.size() > 0 && imagelist[(int) id].isFile()) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            Uri uri = Uri.fromFile(imagelist[(int) id].getAbsoluteFile());
            intent.setDataAndType(uri, "application/pdf");
            startActivity(intent);
        }
    }

How to open password protected pdf file by providing password in android application programmatically.PLEASE HELP :(

Depend of app that open file. When you have this code, Android look for apps installed by user which can open pdf files. There are apps that can not open pdf protected by password.

If pdf is protected with password and app can manage it, pdf app ask to user to type it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM