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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:17:31+00:00 2026-06-05T20:17:31+00:00

My app works when initially run, however if it is left in the background

  • 0

My app works when initially run, however if it is left in the background for a while then relaunched by the user I get a RuntimeException “Unable to start activity ComponentInfo…Error inflating class fragment”.

The activity contains a fragment that contains a ListView. The ListView has a custom adapter that contains an ImageView and two TextViews.

When returning to the activity after the app has been in the background and many other apps are used the error is thrown, which leads me to believe its a memory issue, since this does not happen with the emulator only on my device.

How can I make my app avoid this exception?

Here is the LogCat after I resume the app after a long time in the background:

06-15 18:48:41.886: E/AndroidRuntime(10033): FATAL EXCEPTION: main
06-15 18:48:41.886: E/AndroidRuntime(10033): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.scl.tntmg/com.scl.tntmg.NowShowingActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.os.Looper.loop(Looper.java:137)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread.main(ActivityThread.java:4424)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at java.lang.reflect.Method.invokeNative(Native Method)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at java.lang.reflect.Method.invoke(Method.java:511)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at dalvik.system.NativeStart.main(Native Method)
06-15 18:48:41.886: E/AndroidRuntime(10033): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.Activity.setContentView(Activity.java:1835)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.scl.tntmg.NowShowingActivity.onCreate(NowShowingActivity.java:16)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.Activity.performCreate(Activity.java:4465)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-15 18:48:41.886: E/AndroidRuntime(10033):    ... 11 more
06-15 18:48:41.886: E/AndroidRuntime(10033): Caused by: android.os.NetworkOnMainThreadException
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at java.net.InetAddress.getAllByName(InetAddress.java:220)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.scl.tntmg.util.MovieGuideUtil.getData(MovieGuideUtil.java:118)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.scl.tntmg.util.MovieGuideUtil.refreshMovies(MovieGuideUtil.java:183)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.scl.tntmg.util.MovieGuideUtil.getMovies(MovieGuideUtil.java:82)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at com.scl.tntmg.ListFrag.onCreateView(ListFrag.java:49)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:845)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1058)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:289)
06-15 18:48:41.886: E/AndroidRuntime(10033):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
06-15 18:48:41.886: E/AndroidRuntime(10033):    ... 21 more

Here is the activity:

public class NowShowingActivity extends FragmentActivity{

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

    removeNotifications();
}

public void onRestart(){
    super.onRestart();
}

public void onStop(){
    super.onStop();
}

public void onDestroy(){
    super.onDestroy();
}

public void onResume(){
    super.onResume();
    removeNotifications();
}

private void removeNotifications(){
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
    mNotificationManager.cancel(1);
}

public boolean onCreateOptionsMenu(Menu menu){
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mgoptions,menu);
    return true;
}

public boolean onOptionsItemSelected(MenuItem item){
    Intent myIntent;
    switch(item.getItemId()){
        case R.id.theater_details:
            myIntent = new Intent(this, TheaterActivity.class);
            this.startActivity(myIntent);
            return true;
        case R.id.refresh:
            myIntent = new Intent(this, HomeActivity.class);
            this.startActivity(myIntent);
            return true;
        case R.id.about:
            myIntent = new Intent(this, AboutActivity.class);
            this.startActivity(myIntent);
            return true;
        case R.id.settings:
            myIntent = new Intent(this, SettingActivity.class);
            this.startActivity(myIntent);
            return true;
        default:
            return super.onOptionsItemSelected(item);   
    }
}

Here is the nowshowing layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >



<fragment class="com.scl.tntmg.ListFrag"
        android:id="@+id/list"
        android:layout_weight="1"
        android:layout_width="0dp" android:layout_height="fill_parent" >
    <!-- Preview: layout=@layout/list -->
</fragment>

</LinearLayout>
  • 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-05T20:17:32+00:00Added an answer on June 5, 2026 at 8:17 pm

    Your stack trace says

    Caused by: android.os.NetworkOnMainThreadException
    

    which means that maybe the first time, you access network in the right thread, but after resuming the second time, the network is accessed from the UI thread, like here:

    at com.scl.tntmg.util.MovieGuideUtil.getData(MovieGuideUtil.java:118)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app works fine in the simulator but when I run it on my
I have one web app works perfectly under linux with jetty-6.1.22. However, when I
I'm working on an HTML5 mobile app and I initially have the background of
My app works with the Devise gem for authentication, but I want customize it
My app works perfectly fine in the simulator but crashes on the Device. How
Let's say my app works but I love to learn and to find the
can someone tell me why my app works fine on samsumg galaxy nexus but
I am writing an app that plays a url using MPMoviePlayerController. The app works
I'm kind of new at this: My app works great in Linux, where I
I'm currently developing an iPhone app with a webview. The app works on every

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.