To implement up navigation, I would like to return to a specific action in the history stack. If actions on the stack are implemented by different classes, it works like this (assuming I have actions A, B and C on the stack and you want to return to activity A:
protected void onUpPressed() { Intent intent = new Intent(this, A.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); finish(); }
Android will trigger actions from the stack until the activity specified in the intent is the largest (in this case, the activity performed by class A).
However, my application has several actions on the stack implemented by the same class. This is because they display the same data, but for different objects. They were launched with the intent, which indicated both the class that implements the activity and the object to display (either in the extranet package or in the data property).
Now I am looking for code to pull several actions from the history stack again until the corresponding activity is the largest. If I extend the above code and additionally set the package of additional components or the data property, it does not work. Android always corresponds to the first action implemented by the specified class, and does not return far enough. The component package and data property are ignored.
protected void onUpPressed() { Intent intent = new Intent(this, A.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setData(Uri.parse("myapp:" + rootId)); startActivity(intent); finish(); }
So, how can I return to a certain activity? What intent fields can Android compare with to determine if it has found the desired activity?
android android-intent
Codo
source share