应用收盘后退按钮由Intent.ACTION_VIEW查看PDF格式后 [英] Application closing on back button after viewing pdf by Intent.ACTION_VIEW
本文介绍了应用收盘后退按钮由Intent.ACTION_VIEW查看PDF格式后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从活动
打开PDF文件。 PDF被打开,但是当我preSS后退按钮,我的应用程序关闭down.It关闭所有在一起。有没有在logcat中也不例外无论是。下面是我的code。我已经尝试使用 newIntent.setFlags(FLAG_ACTIVITY_NEW_TASK)
;但它表明类似的行为。
I need to open a pdf file from an Activity
. Pdf is opened but when I press the back button, my application shuts down.It closes all together. There's no exception in logcat either. Below is my code. I have tried using newIntent.setFlags(FLAG_ACTIVITY_NEW_TASK)
; but it shows similar behavior.
Intent newIntent = new Intent(Intent.ACTION_VIEW);
newIntent.setDataAndType(path, "application/pdf");
newIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
try{
startActivity(newIntent);
}catch(ActivityNotFoundException ex){
Toast.makeText(this, "Please install a pdf viewer", Toast.LENGTH_LONG).show();
}
我的呼唤回来的活动,如果我不打开PDF按钮code正常工作。
My calling activity back button code works fine if I don't open pdf.
@Override
public void onBackPressed() {
Intent intent = new Intent(current.this, previous.class);
startActivity(intent);
this.finish();
}
有没有办法找回通过 Intent.ACTION_VIEW
推荐答案
删除 this.finish();
和检查
这篇关于应用收盘后退按钮由Intent.ACTION_VIEW查看PDF格式后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文