Git Product home page Git Product logo

Comments (7)

anshul-kai avatar anshul-kai commented on July 2, 2024 1

Thanks for verifying this @yannickoo. From my testing, this happens on a physical device and the behavior is actually intermittent. For my use case, the screen stays on even after I call KeepAwake.deactivate();

from react-native-keep-awake.

yannickoo avatar yannickoo commented on July 2, 2024

I can confirm that it does not work. Unfortunately it's hard to verify this in the simulator :/

This is the current code in KCKeepAwake.java:

public void activate() {
    final Activity activity = getCurrentActivity();

    if (activity != null) {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
        });
    }
}

When checking the documentation it gives us following example:

public class MainActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }
}

from react-native-keep-awake.

yannickoo avatar yannickoo commented on July 2, 2024

Oh, I got some feedback that the screen does not stay active at all.

from react-native-keep-awake.

angelos3lex avatar angelos3lex commented on July 2, 2024

On Android 7.1 my screen also doesn't deactivate. Maybe because of deactivate call? In documentation it says to de-activate by:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON).

instead of:

 activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

from react-native-keep-awake.

chrisregner avatar chrisregner commented on July 2, 2024

Not working on my Android 1.7.2 as well

from react-native-keep-awake.

spedmo avatar spedmo commented on July 2, 2024

+1 Not working on Android in RN 0.59

from react-native-keep-awake.

corbt avatar corbt commented on July 2, 2024

I've decided to deprecate this package in favor of https://docs.expo.io/versions/latest/sdk/keep-awake/. That package does everything this one does, and is better maintained.

from react-native-keep-awake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.