我的应用程序中有一个按钮,当您按下它时会打开一个 pdf 文件。但是,当我退出 pdf 文件然后再次按下按钮时,它会在我上次打开的页面上打开 pdf 文件。是否可以让我的按钮每次从一开始就打开它?如何做到这一点?下面是我的代码:
ImageButton userGuide = (ImageButton) findViewById(R.id.main_menu_user_guide_button);
userGuide.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
SimpleAudioEngine.sharedEngine(context).playEffect(
"sfx/Button_Pop.wav");
File pdfFile = new File(Environment
.getExternalStorageDirectory().getAbsolutePath()
+ "/MathBarsPDFDocument/userg.pdf");
Uri path = Uri.fromFile(pdfFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, "application/pdf");
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
// No application to view, ask to download one
AlertDialog.Builder builder = new AlertDialog.Builder(
HelpMenu.this);
builder.setTitle("No Application Found");
builder.setMessage("Download one from Android Market?");
builder.setPositiveButton("Yes, Please",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
Intent marketIntent = new Intent(
Intent.ACTION_VIEW);
marketIntent.setData(Uri
.parse("market://details?id=com.adobe.reader"));
startActivity(marketIntent);
}
});
builder.setNegativeButton("No, Thanks", null);
builder.create().show();
}
}
});
}