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

  • Home
  • SEARCH
  • 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 8182667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:55:40+00:00 2026-06-07T00:55:40+00:00

Problem: I’ve written State Machine for my android application. It is separate class, extension

  • 0

Problem:

I’ve written State Machine for my android application. It is separate class, extension of Android 4.0.3 StateMachine. And I want this SM could switch activities.
Is it possible to implement?
I mean that such thing as

startActivity(new Intent(CurrentActivity.this, NextActivity.class))

was called not from current activity but inside my state machine.
Thanks and sorry for my bad English.

My solution:

(special thanks to @Jan-Henk)

Inside my CurrentActivity call
stateMachine.sendMessage(SM.MSG_SWITCH_ACTIVITY, CurrentActivity.this);
and inside my State put next code:

@Override
public void exit()
{
    final Intent intent = new Intent(context, NextActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // necessary to avoid exceptions
    context.startActivity(intent);
}

@Override
public boolean processMessage(final Message message)
{
    boolean returnedValue;
    switch(message.what)
    {
        case MSG_SWITCH_ACTIVITY:
            //sendMessage(obtainMessage(MSG_SWITCH_ACTIVITY));
            context = (Context) message.obj; // context - it's a field of my state machine
            transitionTo(nextActivity);
            returnedValue = HANDLED;
        break;
        default:
            returnedValue = NOT_HANDLED;
        break;
    }           
    return returnedValue;
}
  • 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-07T00:55:41+00:00Added an answer on June 7, 2026 at 12:55 am

    You can call startActivity from a Context object, see http://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent).

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

Sidebar

Related Questions

Problem is like this: I have two winapi application's. There is only one way
Problem I have a strange problem. I have written an application in MFC(using VS2003)
Problem: I need an array (datamember) in a parent class A. However, depending on
PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
Problem One: </a> 19-10-2011, 04:49 PM </td> <td class=thread How to fetch the DATE
Problem statement: I want to upload a large binary (such as an audio clip)
Problem: I have 2 classes, DB class and a User class, that will work
Problem is like this: Suppose there are records in dataTable with FruitType as A
Problem background: I have a Qt/QML Symbian application targeting Qt 4.7.4, that requires a
Problem: I'm attempting to disable a radio button by using the code below. This

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.