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 6781739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:39:34+00:00 2026-05-26T16:39:34+00:00

I have 2 activities, the first one is the startup one which in it’s

  • 0

I have 2 activities, the first one is the startup one which in it’s create method causes the second one to be launched, always.
My Robolectric tests pass fine

Activity

public class LoginActivity extends Activity {

/** Called when the activity is first created. */
@Override    

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loginview);

    Intent intent = new Intent(this,MainActivity.class);
    startActivity( intent );
}

I know my activity works fine cause it launches in my device and on the emulator

My Robolectric tests

public void testLoginFirstTime() throws Exception 
{
    LoginActivity activity = new LoginActivity();        
    activity.onCreate(null);
    assertThat(activity, new StartedMatcher(MainActivity.class));        
}

My Robotium test

public void setUp() throws Exception {
    solo = new Solo(getInstrumentation(), getActivity());
}


public void testLoginFirstTime() throws Exception 
{
    solo.assertCurrentActivity("Expected MainActivity to launch", MainActivity.class);
}

What is wrong with my robotium assertion? it always thinks the current activity is login one even though as I watch the emulator/device I can see that Robotium does actually launch the MainActivity but it doesn’t appear to know that the new activity has been launched.
Edit: Meant to say if I add a button to my login view and launch the new activty via a button click then Robotium performs the click and detects the new activity has been launched ok.

Edit:
Looks like its a Robotium limitation
http://groups.google.com/group/robotium-developers/browse_thread/thread/79a70038c16e35e6
However it still leaves me with the issue of how to test my app with robotium the same way as a user will use it, ie, not cheating and starting in a different activity 🙁

  • 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-05-26T16:39:35+00:00Added an answer on May 26, 2026 at 4:39 pm

    You need to use the constructor solo = new Solo(Instrumentation instrumentation) and then after you have created the Solo object you call getActivity() in order to start the first Activity. Then it will work.

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

Sidebar

Related Questions

I have two different activities. The first launches the second one. In the second
I have two activities. The first one executes the second one. Intent i =
I have two Activities: one with VideoView attached to MediaPlayer and the second one.
Here's scenario: I have 2 activities and one service First activity is a landing
I have an Android Honeycomb application with two activities; the first one has a
I have two activities The first one gets some data from a content provider,
I have a sequential workflow with a number of Activities. One of these activities
I have the following layout defined for one of my Activities: <?xml version=1.0 encoding=utf-8?>
Ive got two activities in the same application. the first one is with gui(main
I have one problem using ActivityGroup . I have two activities inside an ActivityGroup

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.