Tell me if you can work with the camera via SurfaceVeiw in Dialog. There is a code to work with the camera with SurfaceView, for the Activity it works great.

class A extends Activity implements...{ ... } 

But if you change Activity to Dialog , the program crashes in this area of ​​the code.

 class A extends Dialog implements ... { ... @Override public void surfaceCreated(SurfaceHolder holder) { try { camera.setPreviewDisplay(holder); // crash here camera.setPreviewCallback(this); } catch (IOException e) { e.printStackTrace(); } } 
  • The program always crashes with a stackrack. If you want to be helped, stop hiding it from us. - Vladyslav Matviienko
  • 06-18 18: 57: 44.934: E / test (22361): Exception 06-18 18: 57: 44.944: E / AndroidRuntime (22361): FATAL EXCEPTION: main 06-18 18: 57: 44.944: E / AndroidRuntime ( 22361): android.view.WindowManager $ BadTokenException: Unable to add window - token 0: 06: 18: 57: 44.944: E / AndroidRuntime (22361): at android.view.ViewRootImpl.setView (ViewRootImpl .java: 656) 06-18 18: 57: 44.944: E / AndroidRuntime (22361): at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:248) 06-18 18: 57: 44.944: E / AndroidRuntime (22361 ): at android.view.WindowManagerImpl.addView (WindowManagerImpl.java - jaroslav
  • the issue has already been resolved - jaroslav
  • what was the solution? I am facing a similar badtokenexception - Raja

0