My app has a restore feature which allows to replace the current database and settings with a the one from a backup file.
The app reacts to the backup opening through intent-filters I have some code to handle the file in an Activity onCreate method
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
String scheme = intent.getScheme();
// valid scheme are files or content in case of mail attachment
if (scheme.equals("file") || scheme.equals("content")) {
uri = getIntent().getData();
} else if (scheme.equals("http") || scheme.equals("https")) {
uri = getIntent().getData();
remoteUri = true;
}
// reset intent
setIntent(new Intent());
processURI(uri, remoteUri);
}
Then in my processURI() function I do all the work and I finish with by displaying a popup telling the user the app will now restart. Then I call system.exit(0);
It works fine but the app is reopened automatically on the same Activity with the original intent even though I reset it before... how can I avoid this ?