У меня большая проблема с моим приложением, так как оно часто вылетает, но никогда в одном месте.
До того, как оно работало нормально, у меня было повторение метода во всех приложениях, которые проверяли язык.Я решил поместить метод в статический класс с именем Utils, и, возможно, в этом проблема ???
Вот как начинаются все мои действия:
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);
}
это делает утечки памяти?я должен избегать использования статического класса для этого?как я мог не повторять один и тот же код 20 раз?
ошибки, которые я получаю:
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
речь идет о растровом изображении, но здесь только nly может быть фоновым изображением, котороеодинаково для всех видов деятельности, но как я могу решить это?
спасибо