make sure the device doesnt fall asleep while the flashlight is on

- does not work with the widget, only with the app itself
This commit is contained in:
tibbi 2016-01-06 21:15:46 +01:00
parent a4683d5417
commit 7e90b6c8c7

View File

@ -3,6 +3,7 @@ package flashlight.simplemobiletools.com;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.Toast;
@ -61,11 +62,13 @@ public class MainActivity extends AppCompatActivity implements MyCamera {
@Override
public void enableFlashlight() {
toggleBtn.setImageResource(R.mipmap.flashlight_big_on);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override
public void disableFlashlight() {
toggleBtn.setImageResource(R.mipmap.flashlight_big_off);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override