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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:04:34+00:00 2026-06-06T09:04:34+00:00

I have a big problem with my app as it crashes often but never

  • 0

I have a big problem with my app as it crashes often but never at the same spot.

Before it was working fine but I had a method repeated in every app that checked for the language. I have decided to put the method in a static class called Utils and maybe this is the problem???

here is how all my activities start:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //set up idioma
    sharedPrefs =PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    idioma = sharedPrefs.getString("listPref2", "catala");
    idioma=Utils.updateLanguage(getApplicationContext(), idioma);

    setContentView(R.layout.list_event);

}

does this do memory leaks? should I avoid using the static class for this? how could I don not to repeat the same code 20 times?

the errors I get:

06-28 15:24:31.411: INFO/ActivityManager(52): Starting activity: Intent { act=android.intent.action.VIEW cmp=com.tresipunt.butxaca.com/com.tresipunt.butxaca.AllEventsDetailsTabs (has extras) }
06-28 15:24:31.551: ERROR/dalvikvm-heap(341): 2160000-byte external allocation too large for this process.
06-28 15:24:31.551: ERROR/(341): VM won't let us allocate 2160000 bytes
06-28 15:24:31.551: DEBUG/AndroidRuntime(341): Shutting down VM
06-28 15:24:31.551: WARN/dalvikvm(341): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
06-28 15:24:31.561: ERROR/AndroidRuntime(341): Uncaught handler: thread main exiting due to uncaught exception
06-28 15:24:31.592: ERROR/AndroidRuntime(341): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tresipunt.butxaca.com/com.tresipunt.butxaca.AllEventsDetailsTabs}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tresipunt.butxaca.com/com.tresipunt.butxaca.AllEventsDetailsTabList}: android.view.InflateException: Binary XML file line #21: Error inflating class java.lang.reflect.Constructor
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.os.Looper.loop(Looper.java:123)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.main(ActivityThread.java:4203)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at java.lang.reflect.Method.invokeNative(Native Method)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at java.lang.reflect.Method.invoke(Method.java:521)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at dalvik.system.NativeStart.main(Native Method)
06-28 15:24:31.592: ERROR/AndroidRuntime(341): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tresipunt.butxaca.com/com.tresipunt.butxaca.AllEventsDetailsTabList}: android.view.InflateException: Binary XML file line #21: Error inflating class java.lang.reflect.Constructor
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2242)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:631)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.widget.TabHost.setCurrentTab(TabHost.java:317)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.widget.TabHost.addTab(TabHost.java:210)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.tresipunt.butxaca.AllEventsDetailsTabs.onCreate(AllEventsDetailsTabs.java:101)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     ... 11 more
06-28 15:24:31.592: ERROR/AndroidRuntime(341): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class java.lang.reflect.Constructor
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.Activity.setContentView(Activity.java:1620)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at com.tresipunt.butxaca.AllEventsDetailsTabList.onCreate(AllEventsDetailsTabList.java:117)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     ... 20 more
06-28 15:24:31.592: ERROR/AndroidRuntime(341): Caused by: java.lang.reflect.InvocationTargetException
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.widget.ListView.<init>(ListView.java:148)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at java.lang.reflect.Constructor.constructNative(Native Method)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createView(LayoutInflater.java:499)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     ... 31 more
06-28 15:24:31.592: ERROR/AndroidRuntime(341): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.nativeCreate(Native Method)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:476)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:322)
06-28 15:24:31.592: ERROR/AndroidRuntime(341):     at android.graphics.drawable.Drawable.createFromResourceStr

it is talking about a bitmap but the nly bitmap here can be the background image which is the same for all activities but how could I solve that?

thank you

  • 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-06T09:04:35+00:00Added an answer on June 6, 2026 at 9:04 am

    should I avoid using the static class for this?

    I think it’s ok to use a static class but you have to keep in mind, that the context you use use should only be used within the lifetime of the application or activity object where you got it from. This means if you access the context object and the original object it is attached to is already destroyed, you might get a null exception.

    how could I don not to repeat the same code 20 times?

    One way to do this is to create a base Activity class which contains all of the common things that need to be done in all your activities. And then, just have each of your unique activities extend this common Activity class.

    For example, in your common Activity class:

    public CommonActivityBase extends Activity {
        public onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
    
        //set up idioma
        sharedPrefs =PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        idioma = sharedPrefs.getString("listPref2", "catala");
        idioma=Utils.updateLanguage(getApplicationContext(), idioma);
    
        }
        ...
    }
    

    And in your activity classes:

    public ActivityA extends CommonActivityBase {
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstance);
            ....  // do other stuff specific to this activity
            setContentView(R.layout.list_event);
        }
        ....
    }
    
    public ActivityB extends CommonActivityBase {
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstance);
            ....  // do other stuff specific to this activity
            setContentView(R.layout.list_for_activity_b);
        }
        ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have big problem when I am trying to deploy my app over clickonce.
I have a big problem. I had a configuration which worked properly till today.
I have a big problem with Google Chrome and its memory. My app is
We have a test case that crashes our big MFC-based app with a heap
I have a little/big problem in my app in android.I have 2 activity:Activity1 and
Actually i am get stuck in a big problem..I have created an app from
I'm using editor from Kendo UI, so I have big problem. I don't know
I have a big problem. I use excel auto filter function, at the end
I have a big problem that a recursive treeview doesn't update any childs if
I have a big problem that is I have implemented a scheduler in my

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.