user255607
user255607

Reputation: 1869

Mix of questions about Android activity/intent behaviour

Can an activity send itself an intent ?

Can an activity A send a "start" intent to start another activity B (onCreate() of B invoked) and B send again another start intent to A to make it appear again (instead of using finish()) ?

Is there another intent to make A appear again on foreground ?

If A has launched services with Java threads is there a risk that those threads are stopped/killed when another activity is started by A ?

Regards, Apple92

Upvotes: 0

Views: 280

Answers (1)

CQM
CQM

Reputation: 44230

Can an activity send itself an intent ? sort of. your next question is basically what I was going to tell you.

Can an activity A send a "start" intent to start another activity B (onCreate() of B invoked) and B send again another start intent to A to make it appear again (instead of using finish()) ? yes, by using a combination of lifecycles (see onPause() and onResume() methods) and startActivityForResult and onActivityResult(..)

Is there another intent to make A appear again on foreground ? what? you can whenever you want. You don't have to call finish() after you startActivity

If A has launched services with Java threads is there a risk that those threads are stopped/killed when another activity is started by A ? No. Only if Activity A is destroyed will that risk come up, and even then it is determined by how you start threads (a thread in a service will not be killed when its calling activity is killed)

Upvotes: 1

Related Questions