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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:25:15+00:00 2026-05-25T23:25:15+00:00

I’m having a strange problem with my app – A have a Fragment Activity

  • 0

I’m having a strange problem with my app –

A have a Fragment Activity which contains a fragment – This fragment starts an AsyncTask onCreate() and cancels the AsyncTask onStop(). My problem arises because, although my Fragment stays running & isn’t obscured it’s onStop() is called almost directly after it’s onCreate().

Does anyone know how to trace why this would be happening?

09-28 11:41:56.785: VERBOSE/SearchFragment1(924): onCreate()
09-28 11:41:56.796: VERBOSE/SearchFragment1(924): onStop()

EDIT

I’ve removed the code from the Fragment and I’m still absolutely baffled – The problem persists! I’ve added a few more lines of logging:

09-28 14:09:00.242: VERBOSE/SearchResultsFragment1(1789): onAttach()
09-28 14:09:00.242: VERBOSE/SearchResultsFragment1(1789): onCreate()
09-28 14:09:00.242: VERBOSE/SearchResultsFragment1(1789): onCreateView()
09-28 14:09:00.242: VERBOSE/SearchResultsFragment1(1789): onActivityCreated()
09-28 14:09:00.242: VERBOSE/SearchResultsFragment1(1789): onStart()
09-28 14:09:00.246: VERBOSE/SearchResultsFragment1(1789): onStop()
09-28 14:09:00.246: VERBOSE/SearchResultsFragment1(1789): onStart()
09-28 14:09:00.246: VERBOSE/SearchResultsFragment1(1789): onResume()

The above behaviour is… baffling. The code used in the Activity looks like this:

if(savedInstanceState == null) 
{
    try {
        FragmentTransaction transaction= getSupportFragmentManager().beginTransaction();    
        Fragment currentFragment= (Fragment)Class.forName(getIntent().getAction()).newInstance();
        transaction.replace(R.id.singlePane, currentFragment);  
        transaction.commit();
    } catch ...

This is the Fragment as it stands during debug:

private static final boolean LOGGING_ENABLED = true;
private static int global_creation_count = 0;
private int local_count = global_creation_count;

@Override
public void onAttach(Activity activity) {   
    super.onAttach(activity);
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onAttach()");
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    global_creation_count+=1;       
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onCreate()");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onCreateView()");
    return super.onCreateView(inflater, container, savedInstanceState);     
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, 
    "onActivityCreated()");
}

@Override
public void onStart() {
    super.onStart();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onStart()");
}       

@Override
public void onResume() {
    super.onResume();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onResume()");
}

// Fragment is active

@Override
public void onPause() {
    super.onPause();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onPause()");
}   

@Override
public void onStop() {
    super.onStop();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onStop()");
}   

@Override
public void onDestroyView() {
    super.onDestroyView();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onDestroyView()");
}

@Override
public void onDestroy() {   
    super.onDestroy();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onDestroy()");
}

@Override
public void onDetach() {    
    super.onDetach();
    if(LOGGING_ENABLED) Log.v(this.getClass().getSimpleName() + local_count, "onDetach()");
}   

EDIT2

From the code it seems that the onStop() is being called directly after onStart(). I’ve tried to see if it’s being called at the same time as onStart() by adding a Thread.sleep(1000) in onCreateView(). The output is the same – which makes me beleive the onStop() is being called/caused directly from Fragment creation process.

EDIT3

Stacktrace when breaking on onStop():
enter image description here

I’m going to try and attach the source code and step through to discover where the problem is.

  • 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-25T23:25:15+00:00Added an answer on May 25, 2026 at 11:25 pm

    Still don’t know what it was trying to do… I researched on where to get the source code for the class’s involved in called onStop() and found that the source for android-support-v4.jar comes packaged along with the jar in the SDK.

    After attaching this source though I soon found it was out of sync and that my android-support-v4.jar was vastly different to the one shipped with the current version of the SDK.

    Replacing the jar with the one packaged with the SDK fixes the problem instantly and no onStop() is called after onStart(). Not sure what bug was causing this but the latest version seems to fix it quite handily.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.