我試圖通過從另一個活動推出的活動:的OutOfMemoryError上推出了新的活動
Intent loginActivity = new Intent(mainAppContext,LoginActivity.class);
loginActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
loginActivity.putExtra("Message", mainAppContext.getResources().getString(R.string.RegisteringUserAPIFailure));
mainAppContext.startActivity(loginActivity);
新的活動佈局只有兩個圖像一個ImageView
7KB和11KB的另一ImageButton
僅此而已。哪些不應該生成OutOfMemoryError?
但這生成以下錯誤:
03-21 21:20:14.318 20567-20567/com.administrator.myproject E/art: Throwing OutOfMemoryError "Failed to allocate a 108000012 byte allocation with 9062644 free bytes and 8MB until OOM"
03-21 21:20:14.383 20567-20567/com.administrator.myproject E/art: Throwing OutOfMemoryError "Failed to allocate a 108000012 byte allocation with 9062596 free bytes and 8MB until OOM"
03-21 21:20:14.423 20567-20567/com.administrator.myproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.administrator.myproject, PID: 20567
java.lang.OutOfMemoryError: Failed to allocate a 108000012 byte allocation with 9062596 free bytes and 8MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:942)
at android.graphics.Bitmap.createBitmap(Bitmap.java:913)
at android.graphics.Bitmap.createBitmap(Bitmap.java:880)
at android.graphics.drawable.VectorDrawable$VectorDrawableState.createCachedBitmapIfNeeded(VectorDrawable.java:713)
at android.graphics.drawable.VectorDrawable.draw(VectorDrawable.java:280)
at android.widget.ImageView.onDraw(ImageView.java:1197)
at android.view.View.draw(View.java:16536)
at android.view.View.updateDisplayListIfDirty(View.java:15466)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.draw(View.java:16539)
at android.view.View.updateDisplayListIfDirty(View.java:15466)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.draw(View.java:16539)
at android.view.View.updateDisplayListIfDirty(View.java:15466)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.updateDisplayListIfDirty(View.java:15461)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.updateDisplayListIfDirty(View.java:15461)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.updateDisplayListIfDirty(View.java:15461)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.updateDisplayListIfDirty(View.java:15461)
at android.view.View.getDisplayList(View.java:15488)
at android.view.View.draw(View.java:16258)
at android.view.ViewGroup.drawChild(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
at android.view.View.draw(View.java:16539)
at android.widget.FrameLayout.draw(FrameLayout.java:598)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:3111)
at android.view.View.updateDisplayListIfDirty(View.java:15466)
at android.view.View.getDisplayList(View.java:15488)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:309)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:315)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:354)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2942)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2739)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2325)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1301)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7021)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at a
-
<ImageView
android:id="@+id/imageView1"
android:layout_width="@dimen/dimen_8"
android:layout_height="@dimen/dimen_8"
android:layout_below="@+id/login_progress"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:src="@drawable/application_logo_color" />
<ImageButton
android:id="@+id/gplus_sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_1"
android:background="@color/transparent"
android:elevation="8dp"
android:src="@drawable/google_plus_sign_in_button" />
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ImageButton gPlusSignInButton = (ImageButton) findViewById(R.id.gplus_sign_in_button);
SnackBarView = (View) gPlusSignInButton;
gPlusSignInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(SnackBarView, getResources().getString(R.string.SendingGoogleSignIn), Snackbar.LENGTH_INDEFINITE).setAction("Action", null).show();
googlePlusSignIn();
}
});
Bundle extras = getIntent().getExtras();
if (extras != null) {
String message = extras.getString("Message");
Snackbar.make(SnackBarView, message, Snackbar.LENGTH_INDEFINITE).setAction("Action", null).show();
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="2500dp"
android:height="1200dp"
android:viewportWidth="2500.0"
android:viewportHeight="1200.0">
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/dimen_8"
android:height="51dp"
android:viewportWidth="346.0"
android:viewportHeight="72.0">
「新活動佈局只有兩個圖像7KB的一個ImageView的和另一個11kb的ImageButton就是這樣「 - 一些'ImageView'顯示一個'VectorDrawable'。根據爲VectorDrawable生成的位圖分配的大小,ImageView大小看起來很大(相當於一邊的5196個像素)。 – CommonsWare
你能告訴我們新的Activity的onCreate方法的代碼嗎? –
兩者都是可繪製的,我還在上面添加了佈局標記。 – Maven