银河s3不会拍照

时间:2012-11-14 15:46:42

标签: android android-activity camera

所以我正在尝试运行图片捕捉将图像加载到imageview中,它在三星galaxy mini和galaxy one上运行良好,但是在三星galaxy s3上它在返回应用程序时崩溃了。 我开始活动的代码:

  Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  startActivityForResult(cameraIntent, 11); 

我收到活动结果的代码:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == RESULT_OK && requestCode == 11) { 
        ImageView slika=(ImageView)findViewById(R.id.nesrecaSlika1);
        Bitmap photo = (Bitmap) data.getExtras().get("data");            
        slika.setImageBitmap(photo);

    }  

然而,当我调试时,代码中没有错误,但应用程序只是在返回时崩溃。如果我没有拍照就回去,它可以正常工作。在我的logcat中,我遇到了这个问题:

11-14 16:39:08.976: E/AndroidRuntime(19745): FATAL EXCEPTION: main
11-14 16:39:08.976: E/AndroidRuntime(19745): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:702)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:316)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:218)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:143)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.view.Window$LocalWindowManager.addView(Window.java:547)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.widget.PopupWindow.invokePopup(PopupWindow.java:1001)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:858)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:822)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at com.motiviti.zmapp.MainActivity.showPopup(MainActivity.java:310)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at com.motiviti.zmapp.MainActivity.access$10(MainActivity.java:297)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at com.motiviti.zmapp.MainActivity$8.run(MainActivity.java:287)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.os.Handler.handleCallback(Handler.java:605)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.os.Looper.loop(Looper.java:137)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at android.app.ActivityThread.main(ActivityThread.java:4514)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at java.lang.reflect.Method.invokeNative(Native Method)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at java.lang.reflect.Method.invoke(Method.java:511)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 16:39:08.976: E/AndroidRuntime(19745):    at dalvik.system.NativeStart.main(Native Method)

任何想法可能是什么?

我用该代码进行了测试:

 Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
 startActivity(cameraIntent);

回到我的应用程序时偷了它崩溃。

0 个答案:

没有答案