I created an application which uses camera and during the appplication execution the screen is always on.
In the onCreate() method I added the lock:
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); this.mWakeLock.acquire(); And this is the overriden onStop() method:
@Override protected void onStop() { if(mWakeLock.isHeld()) { mWakeLock.release(); } super.onStop(); } But after the application termination the screen remains on all the time and if I run the camera application it encounters an error which obviously appears because the camera resources are not released.
Does anyone know how to release all resources on application termination?