我对四项具体活动的意图遇到了一些麻烦。它随机崩溃,我无法理解为什么会这样。它发生在四个活动上,我认为这与未正确接收意图的活动有关。我使用了差异检查程序来验证此代码与不崩溃的活动之间没有任何区别,并且没有任何差异。更有趣的是,它似乎重新启动了在崩溃之前的活动,并且通常继续通过该活动而没有崩溃,但随后又崩溃了这四个活动中的另一个。
这是我的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}
如果我需要发布更多代码/ logcat读数,请告诉我。我是这里的新手,所以请尽可能详尽地解释你的答案。
感谢。
更新
活动中的一些代码:
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);
}
}
更新2
更多logcat读数......
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
答案 0 :(得分:0)
看起来你在你的主线程上做了太多而且加载了一个非常大的图像(在主线程上不好)。该映像导致VM耗尽堆内存:
08-15 20:08:05.380 1547-1547/tk.emposoft.wirewizard E/dalvikvm-heap﹕ Out of memory on a 106990144-byte allocation.
您需要在读入图像时缩放图像并在后台线程上执行加载。