简体   繁体   中英

Android: Two Activities Simultaneously

After searching for similar questions here on StackOverflow, I've come to the understanding that you cannot run 2 activities simultaneously. Is there any way around this? I've read about Services and Asynctasks , but I'm still a little bit confused.

I thought Threading/Intents/Handlers would work, but i'm finding that threading is a way to go from one activity to another (please correct me if I'm wrong) and not running two things at once.

Let's say I wanted to combine an android MediaPlayer activity and a video recording activity, while still being able to have the two interact with each other, would it be possible in android? is it possible to have the camera running while having a video play/having a separate activity run within the same application? If so, How?

I found a question here that addresses a similar issue( https://stackoverflow.com/questions/12021518/android-simultaneous-record-and-playback-different-sources ), But it is unanswered.

Any suggestions or advice will be greatly appreciated!

Intent , Handler and Thread are really 3 different things.

An Intent is basically a message to say you did or want something to happen. Depending on the intent, apps or the OS might be listening for it and will react accordingly. So an intend is used to navigate from one activity to another. (For you example : A camera intent can be used a request to capture a picture or video clip through an existing camera app and then returns control back to your application.)

A Thread must be created to execute long running jobs. If you do not explicitly start it in its own thread then it will run on the main (UI) thread which may be noticeable as jittery or slow to respond interface by your users.

A Handler is very convenient object to communicate between 2 threads (for instance : a background thread need to update the UI. You can use a Handler to post some Runnable from your background thread to the UI thread).

As @krishna has mentioned you can try fragments...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM