3

So i'm trying to run picture capture to load image into imageview, it works fine on samsung galaxy mini and galaxy one, however on samsung galaxy s3 it crashes when returning to the app. my code to start the activity:

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

And code where i recieve activity result:

@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);

    }  

However when i was debugging there is no error in the code, but app just crashes on return. If i go back without taking picture it works fine on. In my logcat i get that problem:

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)

Any ideas what it might be?

I jsut tested with that code:

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

And steal it crashes when returning to my app.

4

0 回答 0