質問

In my Android application I need to Override the onResume() method to check which of two possible activities just finished. The user will either have entered an amount of money, or named and chosen a percent for a category. How can I do that? Also, if a user presses home and then goes back to my app, is onResume() called? If so, I can just call super.onResume(), right?

I have three classes: PaySaver, NewSavingCategory, and NewPaycheck. PaySaver.java is the main Activity, and there are two buttons: New Paycheck (launches a dialog box where a user inputs $ (NewPaycheck.java)) and New Saving Category (launches a dialogbox where a user inputs a name and a % (NewSavingCategory.java)). When the dialog box is closed via an enter button, I want the main activity to be updated with the information entered.

Thanks!

役に立ちましたか?

解決

How can I do that?

Most likely, you don't. Both of those other activities updated your central data model. In onResume(), you update your UI from that same central data model. Hence, it does not matter where the user came from -- you are grabbing the latest data.

Also, if a user presses home and then goes back to my app, is onResume() called?

On the activity they return to, yes.

If so, I can just call super.onResume(), right?

Not only "can" you do that, you have to call super.onResume(), or your activity will crash.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top