• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is the library that keeps the screen on until user is looking at the screen.

Prevent-Screen-Off

Build Status Download Hex.pm API

GitHub Main

Featured in:

What is this library for?

  • Ideally, when you user is looking at the screen, your application should not turn the screen off. This is huge deal for the blogging, messaging applications because those applications displays textual content to the user. Reading those textual content takes more time to the user. While reading that content (let say anu article) if the screen turns off, because of the screen timeout that is frustrating to the user.
  • This library provides smart handling of the screen on-off. This library prevents screen from turning off if your user is looking at the screen might reading some textual content on the screen. As soon as the user stop looking at the screen it will allow phone screen to turn off.

How this library works?

  • This library users Google Play Services Mobile Vision API to track users eye using the front camera of the device.
  • Library will start tracking user eyes as soon as activity comes into the foreground. If the user is looking at the screen this will prevent screen from turning off.
  • When library detects that the user is not looking at the screen, this will turn off the screen after some time and stop eye tracking the preserve the battery.

How to use this library???

Gradle dependency:

Add these lines to your build.gradle file to start integration.

dependency{
    compile 'com.kevalpatel2106:prevent-screen-off:1.1'
}
  • This library automatically adds android.permission.CAMERA and android.permission.WAKE_LOCK permission in your applications AndroidManifest.xml file.

Initialize in your activity:

  • First you need to inherit AnalyserActivity in the activity which you want to controll screen on/off automatically. The library will synchronise with your activity lifecycle and start and stop eye tracking based on your activity state
  • Implement ScreenListener to receive the callbacks from the library.
public class MainActivity extends AnalyserActivity      //Inherit AnalyseActivity to automatically manage activity callback.
        implements ScreenListner {                      //Implement the listener to get the callbacks
  • Handle the callbacks and errors received from ScreenListener.
public void onScreenMonitoringStart() {
    //This callback will receive when eye tracking algorithm is intilized.
}

@Override
public void onScreenMonitoringStop() {
      //This callback will receive when eye tracking algorithm is stopped.
}

@Override
public void onErrorOccurred(int errorCode) {
    switch (errorCode) {
        case Errors.UNDEFINED:  
            //Error is not defined. 
            //Library won't control the screen on/off anymore.
            break;
        case Errors.CAMERA_PERMISSION_NOT_AVAILABLE:    
            //Camera permission is not available ask for the runtime camera permission
            break;
        case Errors.FRONT_CAMERA_NOT_AVAILABLE:     
            //Device does not have the front camera. 
            //So, this library won't control the screen on/off.
            break;
        case Errors.LOW_LIGHT:       
            //Low light in the surrounding environment so that eye tracking cannot work. 
            //Library won't control the screen on/off anymore. 
            break;
        case Errors.PLAY_SERVICE_NOT_AVAILABLE:     
            //This device doesn't have the play services installed.
            // The SDK will display the error dialog it self. This will stop the eye tracker and will not
            // prevent screen off automatically.
            break;
    }
}

That's it. You are ready to test.

Where to use this library:

  • Tracking user's eye using device camera consumes more battery. So, it is advisable that you don't integrate automatic screen controll in every screen of you application.
  • You can integrate this features in your application activity, which has more textual content to read. e.g. chat conversation activity in messaging app or activity that displays full article in your blogging application.(This list can be extend for may other users. Let me know if you have more ideas.)

Demo

  • You can download the sample apk from here.

Contribute:

Simple 3 step to contribute into this repo:

  1. Fork the project.
  2. Make required changes and commit.
  3. Generate pull request. Mention all the required description regarding changes you made.

Questions?

Hit me on Twitter

License

Copyright 2017 Keval Patel

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

android-hidden-camera

This library is to take picture using camera without camera preview.
Java
396
star
2

android-ruler-picker

Android custom view that uses ruler for picking the number from given range.
Java
381
star
3

EmoticonGIFKeyboard

An advance Emoticons & GIF keyboard.
Java
273
star
4

PasscodeView

PasscodeView is an Android Library to easily and securely authenticate user with PIN code or using the fingerprint scanner.
Java
272
star
5

android-samples

Repository that contains android tutorial projects and sample applications
Java
229
star
6

FingerprintDialogCompat

FingerprintDialog from Android 28 (P) back ported to Android 23 (M).
Java
104
star
7

android-ringtone-picker

Simple Ringtone Picker dialog which allows you to pick different sounds from ringtone, alarm tone, notification tone and music from external storage.
Java
74
star
8

green-build

An android app for managing your CI builds.
Kotlin
73
star
9

UserAwareVideoView

A customized video view that will automatically pause video is user is not looking at device screen!!!!!
Java
51
star
10

Open-Weather-API-Wrapper

An Android wrapper for the APIs of https://openweathermap.org
Java
22
star
11

remote-storage-android-things

Create an FTP server using on raspberry pi and build your own wireless storage & backup solution for home.
Java
20
star
12

year-in-progress

Deadline tracker
Kotlin
17
star
13

PastryShop

Take home task for the cookpad interview (Sr. Android Engineer) 2018
Kotlin
15
star
14

smart-lens

Get the information of object based on image recognition using TensorFlow.
Java
12
star
15

unity-lamborghini-car

See Lamborghini in the real world.
C#
12
star
16

unity-snake-game

This is smaple 2D unity snake game.
C#
12
star
17

collision-detector-android-things

Get the distance of the object using Android Things & ultrasonic ranging sensor HC-SR04.
Java
10
star
18

pocket-ci

Check your builds from your pocket
Kotlin
9
star
19

smartswitch

Control your home switches remotely from phone using Android Things.
Java
9
star
20

torrent-downloader-android-things

Java
7
star
21

github-issue-cloud-function

๐Ÿ”ฅ Firebase cloud function to post a GitHub issue whenever new crash๐Ÿž reported in firebase crashalytics.
JavaScript
7
star
22

rxbus

Implementation of event bus using Rx for Android.
Java
5
star
23

remote-bluetooth-speaker-android-things

Java
5
star
24

Currency-Converter-App

Currency converter android app
Kotlin
4
star
25

robo-car

Java
4
star
26

crypto-wallet

Demo application for displaying the Bitcoin transaction in Crypto Wallet.
Kotlin
3
star
27

gitlab-ci-android

GitLab CI Docker image to create android builds.
Shell
3
star
28

basic-android

A ready to start from scratch setup for android application project
Java
3
star
29

Github-User-Search

Java
3
star
30

vuforia-barcode-scanner

A barcode scanner for Vuforia based AR applications.
C#
2
star
31

google-home-andorid-things

Protocol Buffer
2
star
32

Stand-Up

Sitting is next cancer.
Kotlin
2
star
33

brew

Kotlin
2
star
34

kevalpatel2106.github.io

Source code for my personal website.
SCSS
2
star
35

rpi-setup

This script will set up your raspberry pi after first boot.
Shell
1
star
36

kevalpatel2106

1
star
37

ar-solar-system

Augmented reality specific model of the solar system using unity in ARCore.
C#
1
star
38

SpinWheelView

Java
1
star
39

home

Java
1
star