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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:26:24+00:00 2026-06-12T12:26:24+00:00

I have a unit test, and after I destroy and finish the app, I

  • 0

I have a unit test, and after I destroy and finish the app, I call getActivity() again to verify it loads correctly. However, it is not calling onCreate()!

public void testHistory() { 
            ...
    mActivity.onPause(); 
    mActivity.finish(); 
    assertTrue(mActivity.getExtractor() == null);
    assertTrue(mActivity.getSettings() == null);
    Log.d(TAG, "**************  Restarting app to verify load.");
    mActivity = getActivity(); 
    assertTrue(mActivity != null);
    assertTrue(mActivity.getExtractor() != null); //////// THIS FAILS!!!

Here is the log

10-07 21:11:40.467: D/SpeedyReader(15441): onPause()
10-07 21:11:40.514: D/SpeedyReader(15441): Saving 5 articles, 1 historical articles...
10-07 21:11:40.709: D/SpeedyReader(15441): Saved articles. success: true, length: 88218
10-07 21:11:40.764: D/SpeedyReader(15441): onStop()
10-07 21:11:40.764: D/SpeedyReader(15441): onDestroy()
10-07 21:11:40.772: D/SpeedyReader(15441): finish()
10-07 21:11:40.772: D/SpeedyReader(15441): **************  Restarting app to verify load.
10-07 21:11:40.772: D/SpeedyReader(15441): finish()
10-07 21:11:40.897: D/SpeedyReader(15441): onCreate()
10-07 21:11:40.944: D/SpeedyReader(15441): finalize()
10-07 21:11:40.944: D/SpeedyReader(15441): Settings.load() wpm:300
10-07 21:11:40.944: D/SpeedyReader(15441): Loading articles...

I don’t know why it says onCreate in the log file. It’s like onCreate() is being called asynchronously! Here is my onCreate().

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Log.d(TAG, "onCreate()");
    ....
    extract = new Extractor();

I tried waitForIdleSync()

    Log.d(TAG, "**************  Restarting app to verify load.");
    mActivity = getActivity(); // restart the app, reload the history
    getInstrumentation().waitForIdleSync(); // ------------ NEW

But that didn’t help.

  • 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-12T12:26:25+00:00Added an answer on June 12, 2026 at 12:26 pm

    Found it! Use

        getInstrumentation().callActivityOnCreate(mActivity, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a unit test that fails because headers are already sent. However, the
I have a unit test called TestMakeAValidCall() . It tests my phone app making
After I have set up all the unit test cases for my android application
I have a unit test that I am writing and have run into an
I have a unit test that creates a mock calls my method to be
I have a unit test where I run a method for every item in
I have a unit test that tests if an Exception is throw, but this
I have a unit test project based on UnitTest++. I usually put a breakpoint
I have a Unit test project for my Application using DUnit framework. This project
I have a unit test like so: [Test] public void DataIn_NoOfRowsReached_CreatesSequentialData() { //Assert MyLogic

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.