I have 3 activities , Activity A and Activity B both can access to Activity C. But at a time,I am using Intent to return back to previous activity.
Intent i = new Intent(C.this , A.class);
Here i use activity C to return back to Activity A. but i want to return to activity A or B from C depending upon who called it. Not using finish(); to return back to activity.
If A calls C then intent i = new Intent (C.this, "dynamically set A");
If B calls C then intent i = new Intent (C.this, "dynamically set B");
在第一个通话中传递一个捆绑包(从A到C或从B到C),并在单击后退操作时检查它的来源。
You can simply use finish() method without using the intent. Look at this:
Button button = this.findViewById(R.id.backButton);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.