My activity's onResume() reads off some "extras" data from the Intent that started it and updates the UI accordingly.

I'd like to add error handling: if the data in the Intent is missing/corrupted, the activity displays a Toast and finishes.

Can I simply call finish() in the onResume() method? I'm worried about some unexpected things given that both are related to the life cycle.

If there are other better ways, I'm interested in these too, but the above seems simplest.

Thanks!

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top