我已经写了一个简单的应用程序,列出了一些pdf文件,当用户点击其中之一,他们在一个pdf查看器中打开(使用adobe这里)。
下面是打开pdf文件的代码:
Uri path = Uri.fromFile(open[filePosition]);
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), "PDF Reader application is not installed in your device", Toast.LENGTH_LONG).show();
}
现在,在pdf查看器中查看文件后,当用户单击“上一步”时,将打开设备的主菜单。
我如何让它返回到我的应用程序,以便用户可以打开另一个文件?
发布于 2013-07-06 12:21:11
删除
finish();
从你的代码,你应该是很好的。
发布于 2013-07-06 12:24:47
删除finish(),然后它应该是:
Uri path = Uri.fromFile(open[filePosition]);
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), "PDF Reader application is not installed in your device", Toast.LENGTH_LONG).show();
}
https://stackoverflow.com/questions/17502901
复制