我的 Android 应用程序中有一个活动试图使用 17 个图像作为位图。但是,当我尝试开始此活动时,它会返回java.lang.OutOfMemoryError
。我真的无法解决这个问题。谁能给我一个确切的解决方案?我onCreate()
的在下面。谢谢你。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seviyor);
activityHead=(ImageView) findViewById(R.id.activityhead1);
shake = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
Options options=new Options();
options.inSampleSize=1;
for(int i=0;i<17;i++){
bmImages[i]=BitmapFactory.decodeResource(getResources(),drwbles[i] , options);
}
initilizeToastBackground();
initilizeButtonsFor16Leafs();
initilize16Lisener();
resultIntent=new Intent(this,ResultFrame.class);
fortuneCon=16;
for(int i=0;i<17;i++){
leafs[i]=(ImageView) findViewById(leafIDs[i]);
}
for(int i=0;i<17;i++){
leafs[i].setImageBitmap(bmImages[i]);
}
Bundle frompreviousInent=getIntent().getExtras();
categoryName=frompreviousInent.getString("category");
setHeadOfActivity();
}
这是我的 LogCat ...
07-12 15:21:11.465: E/AndroidRuntime(23419): FATAL EXCEPTION: main
07-12 15:21:11.465: E/AndroidRuntime(23419): java.lang.OutOfMemoryError
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.Bitmap.nativeCreate(Native Method)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
07-12 15:21:11.465: E/AndroidRuntime(23419): at com.done.SS.onCreate(SS.java:65)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.Activity.performCreate(Activity.java:4562)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.ActivityThread.access$600(ActivityThread.java:128)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.os.Looper.loop(Looper.java:137)
07-12 15:21:11.465: E/AndroidRuntime(23419): at android.app.ActivityThread.main(ActivityThread.java:4514)
07-12 15:21:11.465: E/AndroidRuntime(23419): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 15:21:11.465: E/AndroidRuntime(23419): at java.lang.reflect.Method.invoke(Method.java:511)
07-12 15:21:11.465: E/AndroidRuntime(23419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-12 15:21:11.465: E/AndroidRuntime(23419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
07-12 15:21:11.465: E/AndroidRuntime(23419): at dalvik.system.NativeStart.main(Native Method)