I've been having some trouble with the intents on four specific activities. It randomly crashes, and I can't understand why this is the case. It occurs on four activities, and I think it has something to do with the activity not receiving the intent properly. I have used a diff-checker to verify that there's nothing different between this code and the activities that do not crash, and it turned up no differences. Even more interestingly, it seems to restart the activity that before the one that crashed, and continues normally past that activity with no crashing, but then crashes on another one of those four activities.
Here's my Logcat:
08-09 16:16:39.031 384-399/system_process I/Choreographer﹕ Skipped 75 frames! The application may be doing too much work on its main thread.
08-09 16:16:40.081 384-398/system_process I/Choreographer﹕ Skipped 83 frames! The application may be doing too much work on its main thread.
08-09 16:16:40.831 1064-1064/tk.test.wirewizard I/Process﹕ Sending signal. PID: 1064 SIG: 9
08-09 16:16:42.011 384-607/system_process I/ActivityManager﹕ Process tk.test.wirewizard (pid 1064) has died.
08-09 16:16:42.081 384-396/system_process I/WindowState﹕ WIN DEATH: Window{b22499a0 u0 tk.test.wirewizard/tk.test.wirewizard.Start}
Let me know if I need to post more code/logcat readouts. I am a newbie at this, so please explain your answers as thoroughly as possible.
Thanks.
UPDATE:
Some code from an activity:
package tk.test.wirewizard;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import tk.test.wirewizard.R;
public class HDMI extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hdmi);
Button b1 = (Button)findViewById(R.id.button);
Button b2 = (Button)findViewById(R.id.button2);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(HDMI.this, Rcawire.class);
HDMI.this.startActivity(i);
}
});
b2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(HDMI.this, Start.class);
HDMI.this.startActivity(i);
}
});};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.hdmi, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
UPDATE 2
Some more logcat readouts...
08-15 10:49:50.100 1547-1547/tk.test.wirewizard D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
08-15 20:05:54.470 1547-1547/tk.test.wirewizard I/Choreographer﹕ Skipped 73 frames! The application may be doing too much work on its main thread.
08-15 20:07:18.600 1547-1547/tk.test.wirewizard I/Choreographer﹕ Skipped 283 frames! The application may be doing too much work on its main thread.
08-15 20:07:33.210 1547-1547/tk.test.wirewizard I/Choreographer﹕ Skipped 196 frames! The application may be doing too much work on its main thread.
08-15 20:07:36.900 1547-1552/tk.test.wirewizard I/dalvikvm﹕ threadid=3: reacting to signal 3
08-15 20:07:41.650 1547-1552/tk.test.wirewizard I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt'
08-15 20:08:05.010 1547-1547/tk.test.wirewizard D/dalvikvm﹕ GC_FOR_ALLOC freed 52K, 4% free 3252K/3368K, paused 328ms, total 343ms
08-15 20:08:05.010 1547-1547/tk.test.wirewizard I/dalvikvm-heap﹕ Forcing collection of SoftReferences for 106990144-byte allocation
08-15 20:08:05.380 1547-1547/tk.test.wirewizard D/dalvikvm﹕ GC_BEFORE_OOM freed 9K, 4% free 3243K/3368K, paused 369ms, total 369ms
08-15 20:08:05.380 1547-1547/tk.test.wirewizard E/dalvikvm-heap﹕ Out of memory on a 106990144-byte allocation.
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ "main" prio=5 tid=1 RUNNABLE
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0xb1ad5ca8 self=0xb838e380
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ | sysTid=1547 nice=0 sched=0/0 cgrp=apps handle=-1224998572
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ | state=R schedstat=( 27800000000 49530000000 1749 ) utm=1962 stm=818 core=0
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
08-15 20:08:05.400 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.content.res.Resources.loadDrawable(Resources.java:2110)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.widget.ImageView.<init>(ImageView.java:129)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.widget.ImageView.<init>(ImageView.java:119)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at java.lang.reflect.Constructor.constructNative(Native Method)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.createView(LayoutInflater.java:594)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-15 20:08:05.480 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.Activity.setContentView(Activity.java:1929)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at tk.test.wirewizard.HDMI.onCreate(HDMI.java:32)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.Activity.performCreate(Activity.java:5231)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.ActivityThread.access$800(ActivityThread.java:135)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.os.Looper.loop(Looper.java:136)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at android.app.ActivityThread.main(ActivityThread.java:5017)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at java.lang.reflect.Method.invokeNative(Native Method)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at java.lang.reflect.Method.invoke(Method.java:515)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ at dalvik.system.NativeStart.main(Native Method)
08-15 20:08:05.550 1547-1547/tk.test.wirewizard I/dalvikvm﹕ [ 08-15 20:08:05.650 1547: 1547 D/skia ]
--- allocation failed for scaled bitmap
08-15 20:08:06.090 1547-1547/tk.test.wirewizard D/AndroidRuntime﹕ Shutting down VM
08-15 20:08:06.110 1547-1547/tk.test.wirewizard W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1ad4ba8)
08-15 20:08:06.480 1547-1547/tk.test.wirewizard E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: tk.test.wirewizard, PID: 1547
java.lang.RuntimeException: Unable to start activity
08-15 20:13:07.420 1547-1547/tk.test.wirewizard I/Process﹕ Sending signal. PID: 1547 SIG: 9
It looks like you are doing too much on your main thread and loading a really big image (not good on main thread). The image is causing your VM to run out of heap memory: 08-15 20:08:05.380 1547-1547/tk.emposoft.wirewizard E/dalvikvm-heap﹕ Out of memory on a 106990144-byte allocation.
You need to scale the image as it is read in and do the load on a background thread.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.