简体   繁体   English

如何通过以编程方式在Android应用程序中提供密码来打开受密码保护的pdf文件

[英]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. 我正在开发pdf阅读器,因为android没有任何本机pdf查看器,所以我必须使用第三方pdf查看器。 in that case i have chose the Adobe pdf viewer for android. 在这种情况下,我选择了Android的Adobe pdf查看器。 I can open pdf file which are stored in sdcard of my device. 我可以打开存储在设备sdcard中的pdf文件。 Now i want to open password protected pdf file from my application. 现在,我想从应用程序中打开受密码保护的pdf文件。 If user wants to open password protected pdf file manually then use have to provide password while opening. 如果用户想手动打开受密码保护的pdf文件,则必须在打开时提供密码。 but i want to open those password pdf file from my application without any password prompt. 但是我想从我的应用程序中打开那些密码pdf文件,而没有任何密码提示。 Application provide the password,[apps knows the password] and without any password prompt, pdf will open. 应用程序提供密码,[应用程序知道密码],并且在没有任何密码提示的情况下,pdf将打开。

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. 当前,如果我想从应用程序中打开任何受密码保护的pdf文件,则会出现密码提示,并需要密码才能打开它。

I am using this code to open pdf from my stored pdf files in the /mnt/sdcard/testfolder 我正在使用此代码从/ mnt / sdcard / testfolder中存储的pdf文件中打开pdf

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 :( 如何通过在Android应用程序中以编程方式提供密码来打开受密码保护的pdf文件。请帮助:(

Depend of app that open file. 取决于打开文件的应用程序。 When you have this code, Android look for apps installed by user which can open pdf files. 有了此代码后,Android会查找用户安装的可打开pdf文件的应用。 There are apps that can not open pdf protected by password. 有些应用无法打开受密码保护的pdf文件。

If pdf is protected with password and app can manage it, pdf app ask to user to type it. 如果pdf受密码保护并且应用可以对其进行管理,则pdf应用会要求用户输入密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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