Thanks for your update.
But it is not my need. I still do not know when the user back from the PDF view to my app view (by pressed back button).
At last I implemented it myself by modify the cordova plugin source code.
To put it simply,
1. Modify file RadaeePDFPlugin.java;
comment:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
change:
mContext.startActivity(intent);
to:
this.cordova.startActivityForResult((CordovaPlugin)this, intent, 0);
and add:
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if(requestCode == 0) {
if(resultCode == cordova.getActivity().RESULT_OK) {
Bundle extras = data.getExtras();// Get data sent by the Intent
String information = extras.getString("fileState"); // data parameter will be send from the other activity.
PluginResult resultado = new PluginResult(PluginResult.Status.OK, information);
resultado.setKeepCallback(true);
PUBLIC_CALLBACKS.sendPluginResult(resultado);
return;
}
else if(resultCode == cordova.getActivity().RESULT_CANCELED) {
PluginResult resultado = new PluginResult(PluginResult.Status.OK, "canceled action, process this in javascript");
resultado.setKeepCallback(true);
PUBLIC_CALLBACKS.sendPluginResult(resultado);
return;
}
}
// Handle other results if exists.
super.onActivityResult(requestCode, resultCode, data);
}
2. Modify file PDFViewAct.java;
change function 'onBackPressed' to:
@Override
public void onBackPressed()
{
if(m_controller == null || m_controller.OnBackPressed())
{
if(m_modified) {
TextView txtView = new TextView(this);
txtView.setText("Document modified\r\nDo you want save it?");
new AlertDialog.Builder(this).setTitle("Exiting").setView(
txtView).setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
m_doc.Save();
Intent mIntent = new Intent();
mIntent.putExtra("fileState", "modifiedAndSaved");
PDFViewAct.this.setResult(RESULT_OK, mIntent);
PDFViewAct.super.onBackPressed();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
Intent mIntent = new Intent();
mIntent.putExtra("fileState", "modifiedAndNotSaved");
PDFViewAct.this.setResult(RESULT_OK, mIntent);
PDFViewAct.super.onBackPressed();
}
}).show();
}
else {
Intent mIntent = new Intent();
mIntent.putExtra("fileState", "notModified");
setResult(RESULT_OK, mIntent);
super.onBackPressed();
}
}
}
Now when user back from PDF view, I can get file state and do my process.