Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:15:57+00:00 2026-06-07T15:15:57+00:00

My android app needs to run through a sequence of events as in a

  • 0

My android app needs to run through a sequence of events as in a state machine

Event 1: play video # 1

Event 2: load an image and wait for a button press

Event 3: play video #2

etc…

One way of doing would be to generate a separate activity for each event, but with over 20 events, I thought there’s an easier way of doing it.

So I coded a state machine like this:

    int mState = 0;     
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //
    switch(mState) {
    case 0:
        Boolean flag = videoIntent(url0); 
        break;
    case 1:
        flag = loadImage(img1);
    }
    }


public Boolean videoIntent(String video) {
     mBundle.putString("url",video ); 
     Intent myIntent = new Intent();
     myIntent.putExtras(mBundle);
         myIntent.setClass(mySM.this, SM_vPlayer.class);
         startActivity(myIntent);
             mState ++;
    return true;     
 }

public Boolean loadImage(String image) {
    //load image
            mState ++;
    return true;
}

Questions: After starting the intent to play the video (that activity has a listener to wait for the completion) and then finish() is called.

  1. Where will finish() come back to onCreate, onResume or another method?

  2. How do I get back to the switch statement?

  3. Any better ways of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:16:00+00:00Added an answer on June 7, 2026 at 3:16 pm

    The startActivity() method is non-blocking, so your loop (assuming you’re considering a loop in your onCreate() method) would cycle through before the video completed. You could instead perform startActivityForResult(), which would cause a callback in your (current) activity to be called when the started activity finish()’d. You could also load your image without waiting since the new activity will cause yours to be hidden.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing an android app that needs to play a sound every minute
I am developing an android app which needs to activate the GPS. I read
I'm writing an Android app that needs to access GMail, and I'd like to
So I'm writing an android app that needs to grab book price data from
I have an android app which has native code. The native code needs to
Possible Duplicate: Why does Android app run in small window on tablet emulator? i
I am trying to port an android app to run on a blackberry 8800.
I've been looking through the code of the GoogleIO Android app and I notice
I'm writing an android app that needs to copy a file to the /system
I'm developing an Android app that will play a specific audio. This audio is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.