How to Identify the Button Pressed During Screen Transition in Android

Asked 2 years ago, Updated 2 years ago, 123 views

I'm thinking about using Intent to make screen transitions on Android.I would like to reflect the selection of the child screen on the parent screen when I close the screen on the child screen. Is there any way to identify or remember the item that was pressed on the parent screen during the screen transition?

android java kotlin

2022-09-30 21:29

2 Answers

startActivityForResult(Intent,int) and onActivityResult(Intent,CharSequence). What do you think?


2022-09-30 21:29

If multiple configuration state retrieval is required, create a class that inherits the application class and
It is easy to implement if you treat it as a global variable that can be viewed from any screen.
Or create a service and let it run in the background. You can also remember the settings when the screen disappears.

If you want to use Intent to transition the screen again from child activity, when calling the parent

Intent==newIntent(getApplicationContext(), xxxx.class);
boolean 
int.putExtra("VALUE1", value1);
int.putExtra("VALUE2", value2);
startActivity(i);

I think it is also possible to pass it as an argument to the screen that starts like above.
The boot side is either onCreate or onResume and getExtra.
The type passed as an argument can be either an integer or a string.


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.