2

My Phonegap android app got rejected by play store for violating device and Network abuse policy.

This is because of background playing of youtube videos when the screen is in sleep mode i.e If the phone is left idle when a youtube video is playing in the app, screen goes to sleep but the youtube video keeps playing even after the screen is off.

How to detect screen off and pause the video if it's playing ? Is there a Cordova plugin that can do this ?

Thanks in advance.

Ankur Verma
  • 5,793
  • 12
  • 57
  • 93
Supradeep
  • 3,246
  • 1
  • 14
  • 28
  • 1
    It might be the solution just check it out once http://stackoverflow.com/questions/4208458/android-notification-of-screen-off-on – Ankur Verma Nov 23 '16 at 07:52

2 Answers2

1

How about using insomnia plugin and prevent the screen to sleep when the app is playing a video?

Eric
  • 9,870
  • 14
  • 66
  • 102
  • That could be another violation i feel. We can control how our app should perform for various situations but not manipulate users personal settings for our apps performance. – Supradeep Nov 23 '16 at 06:50
  • @HassanALi How can I explain better than 'prevent the screen to sleep when the app is playing a video' ? – Eric Nov 23 '16 at 13:04
  • @HassanALi, there is a documentation for that. This is on the official plugin repository of Cordova. If this is too much work for a beginner, he should quit right off. – Eric Nov 23 '16 at 13:47
  • @suzo, you don't really violate anything... If the user plays a video and doesn't touch his screen, why would his screen goes off?? You basically only prevent something similar to a screen saver to happen. – Eric Nov 23 '16 at 13:48
  • @Eric may be we can use that to not allow the screen to sleep but my requirement is to pause the video when the screen goes off and not to control the screen sleep. thanks :) – Supradeep Nov 23 '16 at 14:11
0

By using phonegap-plugin-mobile-accessibility you can achieve your required funcationailty. This plugin exposes information on the status of various accessibility features of mobile operating systems, including, for example, whether a screen reader is running.

installation Command

cordova plugin add https://github.com/phonegap/phonegap-mobile-accessibility.git

Methods

MobileAccessibility.isScreenReaderRunning

Makes an asynchronous call to native MobileAccessibility to determine if a screen reader is running.

  function isScreenReaderRunningCallback(boolean) {
        if (boolean) {
            console.log("Screen reader: ON");
            // Do something to improve the behavior of the application while a screen reader is active.
        } else {
            console.log("Screen reader: OFF");
        }
    }

    MobileAccessibility.isScreenReaderRunning(isScreenReaderRunningCallback);
Hassan ALi
  • 1,313
  • 1
  • 23
  • 51