gpt4 book ai didi

android - 阅读PDF文件

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:17 26 4
gpt4 key购买 nike

是否可以在 Android 上阅读 pdf 文件,我该怎么做?

最佳答案

你最多只能调用另一个程序用这样的东西打开它(只有你安装了 Quickoffice 才有效)

    public class OpenPdf extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button = (Button) findViewById(R.id.OpenPdfButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File("/sdcard/example.pdf");

if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
}
});
}
}

关于android - 阅读PDF文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5443137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com