I have an android activity that needs to trigger another action (in order to get the password from the user) before its own screen is raised. My code currently does this by calling startActivity () from within onResume (); this is kind of work, but I get inconsistent behavior. Can someone tell me if this approach is legal or not (and if not, how can I do this)?
Thanks Richard.
The challenge startActivity()is onResume()absolutely right. I have many actions that do this, often in response to events that occurred when the activity was stopped.
startActivity()
onResume()
startActivity() , Android , , , Android .
, , .
startActivity() onResume(), . , onResume() ( ) , Android startActivity() .
, , , , , .
, , , , . - "" , , . , . onCreate(), setContentView(). , , , .
onCreate()
setContentView()
.
:
To request a password, you can use a dialog box instead of an Activity.
why not go through this intermediate activity. If you do not need to ask for a password, it can show something else, for example, an animation when you connect to the service (provided that the password is a network thing).