然后我继续运行程序,logcat出来下面错误
05-20 13:49:51.553: WARN/KeyCharacterMap(297): No keyboard for id 0
05-20 13:49:51.563: WARN/KeyCharacterMap(297): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
05-20 13:49:51.743: WARN/InputManagerService(61): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44cfb718
05-20 13:50:01.664: INFO/ActivityManager(61): Starting activity: Intent { act=android.intent.action.VIEW cmp=com.tmxk/.ComsystemActivity (has extras) }
05-20 13:50:02.583: DEBUG/dalvikvm(297): GC freed 4970 objects / 231936 bytes in 294ms
05-20 13:50:11.694: WARN/ActivityManager(61): Launch timeout has expired, giving up wake lock!
05-20 13:50:11.843: WARN/ActivityManager(61): Activity idle timeout for HistoryRecord{44e0cc60 com.tmxk/.ComsystemActivity}
05-20 13:50:13.057: INFO/ActivityManager(61): Displayed activity com.tmxk/.ComsystemActivity: 11288 ms (total 11288 ms)
05-20 13:50:15.074: INFO/ActivityManager(61): Starting activity: Intent { cmp=com.tmxk/.second (has extras) }
05-20 13:50:15.233: DEBUG/AndroidRuntime(297): Shutting down VM
05-20 13:50:15.233: WARN/dalvikvm(297): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-20 13:50:15.243: ERROR/AndroidRuntime(297): Uncaught handler: thread main exiting due to uncaught exception
05-20 13:50:15.314: ERROR/AndroidRuntime(297): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tmxk/com.tmxk.second}: java.lang.NullPointerException
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.os.Looper.loop(Looper.java:123)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread.main(ActivityThread.java:4363)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at java.lang.reflect.Method.invoke(Method.java:521)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at dalvik.system.NativeStart.main(Native Method)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): Caused by: java.lang.NullPointerException
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at com.tmxk.Image.<init>(second.java:31)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at com.tmxk.second.<init>(second.java:53)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at java.lang.Class.newInstanceImpl(Native Method)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at java.lang.Class.newInstance(Class.java:1479)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
05-20 13:50:15.314: ERROR/AndroidRuntime(297): ... 11 more
05-20 13:50:15.353: INFO/Process(61): Sending signal. PID: 297 SIG: 3
05-20 13:50:15.353: INFO/dalvikvm(297): threadid=7: reacting to signal 3
05-20 13:50:15.443: INFO/dalvikvm(297): Wrote stack trace to '/data/anr/traces.txt'
05-20 13:50:18.904: INFO/Process(297): Sending signal. PID: 297 SIG: 9
05-20 13:50:19.183: ERROR/gralloc(61): [unregister] handle 0x39ee90 still locked (state=40000001)
05-20 13:50:19.263: INFO/ActivityManager(61): Process com.tmxk (pid 297) has died.
05-20 13:50:19.273: INFO/WindowManager(61): WIN DEATH: Window{44e30278 com.tmxk/com.tmxk.ComsystemActivity paused=false}
05-20 13:50:19.353: INFO/UsageStats(61): Unexpected resume of com.android.launcher while already resumed in com.tmxk
05-20 13:50:19.443: WARN/InputManagerService(61): Got RemoteException sending setActive(false) notification to pid 297 uid 10034
你的Oncreate方法里面开了多少线程啊!05-20 13:50:15.314: ERROR/AndroidRuntime(297): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tmxk/com.tmxk.second}: java.lang.NullPointerException
这个还报了空指针,你的程序里面错误不少啊!
package com.tmxk; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Random;
import android.app.Activity; import android.content.ContentResolver; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.Toast; class Image{ public Bitmap image; public int imlen;//图像总像素数 public int width = image.getWidth();//图像像素矩阵宽 public int height = image.getHeight();//图像像素高 public int[] pixel=new int[imlen]; }
是不是我的这个Image类定义有错
package com.tmxk; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Random;
import android.app.Activity; import android.content.ContentResolver; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.Toast; class Image{ public Bitmap image; public int imlen;//图像总像素数 public int width = image.getWidth();//图像像素矩阵宽 public int height = image.getHeight();//图像像素高 public int[] pixel=new int[imlen]; }
是不是我的这个Image类定义有错
@liuyufeng: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)这个报错的ACTIVITY点进去,看看为什么空指针。
@神仙都是我自己: thanks