i have searched a lot but i cant find answer so i thought i should post here.
problem
my app works on images which are share by gallery application(i.e default gallery app) and its works fine. but i want to override OnBackPress() method to check whether back button is pressed or not and if backbutton is pressed then i simply want to get calling activity name and want to kill that activity and go back to home.
i can do this if i call another activity form my activity but how can get calling activity name if it is a system app. (i.e gallery application)
keep in mind that my app called when i share images from gallery app so basically i want to get gallery activity to kill it and can go back home safely. i dont wannna go back to gallery app.
i want to simply go back to home and kill that gallery app instead of going back to gallery app.
here is OnBackPressed() method
@Override
public void onBackPressed() {
// do something on back.
// what i tried so far but it is not working
this.getParent().finish();
this.finish();
}
i tired this and hopefully i can go back home safely but still gallery app run in background. i want to kill calling app too.
public void onBackPressed() {
moveTaskToBack(true);
}