nobody can help me to undestand why?

On 8 Giu, 13:41, Paolo <[email protected]> wrote:
> Hi there!
> I've a problem with the Camera, in particular with the
> surfaceDestroyed() callback.
>
> This is my scenario:
>
> The app starts with an activity that shows a splash screen, and after
> 3 seconds it send an Intent to the MyCameraActivity.
> I want to finish the splashscreen activity so in onStop() I call
> finish().
> The CameraActivity starts but if I push the BACK button (my app
> terminate) I see from my log that the surfaceDestroyed() callbacks
> isn't called, where I release the camera source. The consequence is
> simple... when I start the app again, the camera source doesn't result
> free and I have a message error.
>
> Why does it happen this?
>
> Thanks to anyone wants to help me.
>
> *** The Splash Activity ***
>
> @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         requestWindowFeature(Window.FEATURE_NO_TITLE);
>
> getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
> WindowManager.LayoutParams.FLAG_FULLSCREEN);
>         setContentView(R.layout.splash);
>
>         splashHandler = new Handler(){
>                 @Override
>             public void handleMessage(Message msg) {
>                         super.handleMessage(msg);
>                         switch (msg.what) {
>                         case STOPSPLASH:
>                                 startActivity(new 
> Intent(getApplicationContext(),
> CameraView.class));
>                                 break;
>                         }
>             }
>         };
>
>         Message msg = new Message();
>         msg.what = STOPSPLASH;
>         splashHandler.sendMessageDelayed(msg, TIME_SPLASH);
>     }
>
>     @Override
>     public void onPause(){
>         super.onPause();
>         Log.d("DEBUG", "Splash onPause");
>         finish();
>     }
>
> Here part of the code!
>
> *** MyCameraActivity ***
>
> �...@override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         Log.d("DEBUG", "onCreate CameraView");
>        getWindow().setFormat(PixelFormat.TRANSLUCENT);  //aggiungo il
> traslucido
>         requestWindowFeature(Window.FEATURE_NO_TITLE);  //no barra
> titolo
>
> getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
> WindowManager.LayoutParams.FLAG_FULLSCREEN);    //full screen
>
> getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
> WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
>         setContentView(R.layout.camera);
>
>         mSurfaceView = (SurfaceView)findViewById(R.id.camera_surface);
>         mSurfaceHolder = mSurfaceView.getHolder();      //recupero l'holder
> della surfaceview
>         mSurfaceHolder.addCallback(this);       //faccio la bind alla nostra
> activity
>
> mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>
>     }
>
> public void surfaceCreated(SurfaceHolder holder) {
>                 Log.d("DEBUG", "surfaceCreated");
>                 mCamera = Camera.open();
>                 Log.d("DEBUG", "Camera open()");
>         }
>
>         public void surfaceDestroyed(SurfaceHolder holder) {
>                 Log.d("DEBUG", "surfaceDestroyed");
>         mCamera.stopPreview();
>         mPreviewRunning = false;
>         mCamera.release();
>         mCamera = null;
>         Log.d("DEBUG", "Camera rilasciata");
>         }
>
>         public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2,
> int arg3) {
>                 Log.d("DEBUG", "surfaceChanged");
>
>                 if (mPreviewRunning) {
>                         Log.d("DEBUG", "la preview è running ora viene 
> stoppata.");
>                         mCamera.stopPreview();
>                         mPreviewRunning = false;
>
>                 }
>                 //setto le preferenze
>         setPreferencesCamera(arg2, arg3);
>         try {
>                 //lancio la preview
>                 Log.d("DEBUG", "lancio la preview");
>                         mCamera.setPreviewDisplay(arg0);
>                         mCamera.startPreview();
>                         mPreviewRunning = true;
>
>                 } catch (IOException e) {
>                         Log.e("ERROR", "SurfaceChanged: errore Camera 
> setPreviewDisplay");
>                 }
>
>         }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to