我想知道我们能否关闭用于在活动结果后打开隐式意图的应用程序(Adobe reader for Pdf,DocumentsToGo for PPt),例如:
File file = ClassName.this.getFileStreamPath(fileName);
file.setReadable(true, false);
Uri path = Uri.fromFile(file);
contId = contentId[position];
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
try {
startTime = System.currentTimeMillis();
startActivityForResult(intent, 6002);
} catch (ActivityNotFoundException e) {
Toast.makeText(Introduction.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();}
用于查看 pdf,当我按下后退按钮时,我得到 onactivityResult 但之后如果我最小化我的应用程序,adobe reader 将继续在后台打开,我可以在任务管理器中看到带有打开文件的 adobe。对不起,如果我的问题不清楚。答案将不胜感激。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 6002) {
endTime = System.currentTimeMillis();
duration = endTime - startTime;
durationString = "" + duration;
save();
finish();
}
}