2014-10-22 44 views
-1

我的應用程序在大多數設備,但在一些設備的運行不運行,並在Mainactivity.java的錯誤是如何啓動另一個活動時java.lang.OutOfMemoryError

java.lang.OutOfMemoryError 

我想在SplashScreen.java如果不要運行Mainactivity.java,運行其他活動,例如Main2.activity

我用這個代碼,但不工作:

 try { 
     Intent mainactivity = new Intent(SplashScreen.this, MainActivity.class); 
     startActivity(mainactivity); 
     } 
     catch (OutOfMemoryError e) { 
     Intent main2 = new Intent(SplashScreen.this, Main2.class); 
     startActivity(main2); 
     } 

請幫助

my logcat: 

    10-22 08:32:28.311: E/AndroidRuntime(1394): FATAL EXCEPTION: main 
    10-22 08:32:28.311: E/AndroidRuntime(1394): Process: ir.maddahha.imamalip, PID: 1394 
    10-22 08:32:28.311: E/AndroidRuntime(1394): java.lang.OutOfMemoryError 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.content.res.Resources.loadDrawable(Resources.java:2110) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.content.res.Resources.getDrawable(Resources.java:700) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.content.res.Resources.loadDrawable(Resources.java:2092) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.content.res.Resources.getDrawable(Resources.java:700) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.view.View.setBackgroundResource(View.java:15303) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at ir.maddahha.imamalip.Main.onCreate(Main.java:43) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.Activity.performCreate(Activity.java:5231) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.os.Handler.dispatchMessage(Handler.java:102) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.os.Looper.loop(Looper.java:136) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at android.app.ActivityThread.main(ActivityThread.java:5001) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at java.lang.reflect.Method.invokeNative(Native Method) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at java.lang.reflect.Method.invoke(Method.java:515) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
    10-22 08:32:28.311: E/AndroidRuntime(1394):  at dalvik.system.NativeStart.main(Native Method) 
+0

請把logcat – Palak 2014-10-22 09:01:48

回答

2

不能從OutOfMemoryError恢復。此錯誤意味着您的應用程序使用了所有可用內存,操作系統無法爲您分配更多內存。你最好的辦法是試着調查問題的根源。你可能有一些內存泄漏,所以試着解決這個問題。

相關問題