应用程序在setContentView()崩溃

时间:2013-09-23 13:59:53

标签: android android-intent android-emulator

我试图设置一个启动画面工作5秒,然后打开另一个意图,但模拟器粉碎了 我认为它是因为splash layout.xml

09-23 11:21:22.135: W/EGL_emulation(2204): eglSurfaceAttrib not implemented
09-23 11:21:22.605: I/Process(2204): Sending signal. PID: 2204 SIG: 9
09-23 11:21:31.805: D/dalvikvm(2222): GC_FOR_ALLOC freed 66K, 8% free 2583K/2780K, paused 2ms, total 4ms
09-23 11:21:31.805: I/dalvikvm-heap(2222): Grow heap (frag case) to 4.549MB for 1997580-byte allocation
09-23 11:21:31.825: D/dalvikvm(2222): GC_FOR_ALLOC freed 2K, 5% free 4531K/4732K, paused 2ms, total 2ms
09-23 11:21:31.955: W/dalvikvm(2222): threadid=11: thread exiting with uncaught exception (group=0xb2ef8648)
09-23 11:21:31.955: E/AndroidRuntime(2222): FATAL EXCEPTION: Thread-105
09-23 11:21:31.955: E/AndroidRuntime(2222): java.lang.IllegalMonitorStateException: object not locked by thread before wait()
09-23 11:21:31.955: E/AndroidRuntime(2222):     at java.lang.Object.wait(Native Method)
09-23 11:21:31.955: E/AndroidRuntime(2222):     at java.lang.Object.wait(Object.java:401)
09-23 11:21:31.955: E/AndroidRuntime(2222):     at com.app.locator.Splash$1.run(Splash.java:19)
09-23 11:21:31.995: D/libEGL(2222): loaded /system/lib/egl/libEGL_emulation.so
09-23 11:21:31.995: D/(2222): HostConnection::get() New Host Connection established 0xb9481bf0, tid 2222
09-23 11:21:32.025: D/libEGL(2222): loaded /system/lib/egl/libGLESv1_CM_emulation.so
09-23 11:21:32.025: D/libEGL(2222): loaded /system/lib/egl/libGLESv2_emulation.so
09-23 11:21:32.255: W/EGL_emulation(2222): eglSurfaceAttrib not implemented
09-23 11:21:32.295: D/OpenGLRenderer(2222): Enabling debug mode 0
09-23 11:21:32.945: W/EGL_emulation(2222): eglSurfaceAttrib not implemented

1 个答案:

答案 0 :(得分:0)

您的启动画面似乎使用了太大的位图。尝试downscale it。 例如:

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    //get splash image width, it will be equal display width
    final int windowWidth = metrics.widthPixels;

    final int statusBarHeight = (int) Math.ceil(STATUS_BAR_HEIGHT * getResources().getDisplayMetrics().density);
    //get splash image height (display height - status bar height)
    final int windowHeight = metrics.heightPixels - statusBarHeight;

    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    final int inSampleSize = ImageUtils.calculateInSampleSize(options, windowWidth, windowHeight);
    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;

    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resId, options);