Code Monkey home page Code Monkey logo

scheduler-plugin's Introduction

Important Notice

Please be aware that I'm struggling to maintain this plugin. Even after considerable effort, I have been unable to produce a reliable development environment.

While I will work to rectify this, neither Android or Cordova/ Phonegap development represent a priority to me. Neither present me with paid income or particularly excite me enough to put aside other projects.

I will make attempts to be more active in responding to questions โ€“ and apologies for any previous delays.

Please keep the above in mind before actively using this plugin.

Scheduler Plugin

Quick summary

Plugin which allows you to schedule an alarm which will start your app.

Getting started

The plugin can be installed using the following commands (this assumes you are familiar with the [Cordova Android Getting Started] (http://docs.phonegap.com/en/3.3.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide)):

  • cordova create hello com.example.hello "HelloWorld"
  • cd hello
  • cordova platform add android
  • cordova plugin add https://github.com/Red-Folder/Scheduler-Plugin.git
  • Amend the hello\www\config.xml, replace any existing content node with: <content src="scheduler.html" /> (add the content node if not already present)
  • cordova build
  • Add the following to platforms\android\src\com\example\hello\HelloWorld.java in the onCreate() method:
// You will also need to add - import com.red_folder.phonegap.plugin.scheduler.ActivityHelper; at the top of the java file
ActivityHelper.onCreate(this);
  • You should then be able to open, build the Android project (platforms\android) within Eclipse

You should be able to run the example.

Further documentation can be found at https://github.com/Red-Folder/Scheduler-Plugin/wiki

JavaScript reference can be found at https://github.com/Red-Folder/Scheduler-Plugin/wiki/Javascript-Method-Reference

Development

This is a very early version of the plugin and is under active development.

Please see the [Enhancements List] (https://github.com/Red-Folder/Scheduler-Plugin/issues?labels=enhancement&page=1&state=open) for the planned changes.

Please read the [Release Notes] (https://github.com/Red-Folder/Scheduler-Plugin/wiki/Release-Notes) between version as function signature is very likely to change while in active development.

Questions and Support

If you have problems, then please log an issue: https://github.com/Red-Folder/Scheduler-Plugin/issues?state=open

As the plugin is updated (for new features or fixes) I will tweet via @FolderRed and blog http://red-folder.blogspot.co.uk/

Spread the love

If you find the Plugin useful then spread the love.

All the work I do on the Plugin is done in my spare time - time I would otherwise be spending taking my wife out for a nice meal or helping my lad find vinyl records (he's currently very much into The Smiths, Fleetwood Mac and Kate Bush).

The Plugin is free and will always remain free. I will continue to develop, maintain and distribute the Plugin under the Apache 2.0 License.

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=E64TCFQ3NLHZ8

Licence

Copyright 2014 Red Folder Consultancy Ltd

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.

scheduler-plugin's People

Contributors

red-folder avatar luigi37 avatar

Stargazers

 avatar  avatar Textras avatar Artyr Prokopenko avatar praetoriani avatar Lucky Onagite avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

scheduler-plugin's Issues

isServiceRunning returning true even when it isn't

From Luigi;

Something strange in

    if (appClassName != null) {
        //if (AppHelper.isServiceRunning(context, appClassName)) {
        //    Log.d(TAG, appClassName + " already running");
        //} else {
            Log.d(TAG, appClassName + " starting");
            AppHelper.startActivity(context, appClassName);
        //}
    }

I had to comment out as per above because it was telling me the app was running.

Anyway it should not arm if it gets restarted even if already on (at least as long as manifest contains "singleistance".

The other positive effect is that it brings in foreground the app, which again is a wanted behaviour...

Run the alarm silently

Hello,

First of all, thank you for sharing your magnificent work.

I understand that functions that will be performed when the alarm is triggered must be set in the function
function handleExtras(data)

What I want to achieve is that when the alarm is triggered, the function I place there dont open the app, just perform the actions and then show a notification to the user if needed. How can I do that? I tried placing navigator.app.exitApp; but doesnt seem to exit the app.

I dont want to annoy the user and dont want the user know the app was running in the background.

I also noted your background service plugin but dont know java very well to program in native. Also, since this alarm will work only once at day, Im not sure if its viable to use a background service, cause it seems to waste device's resources that way (not sure about this last thing).

Thank you

StartActivity when app is paused

Hello,
thank you for the plugin!!!
it works fine but when the activity is paused or in background and you lock the screen the app will not been started...

ive tryed " android:launchMode="singleIstance"" but this does not work...

can you help me?

greetings

Issue with alarm

Hi, I really want to use your plugin but when i used your template it didnt work. It didnt even lunched the app. All i did was downloading the plugin via cordova command and put the template into the index. thats it. Suggest something please :/

Do we need to provide UTC offset for different timezones

Needs to be tested, but we may need to store the timezone offset. Seems like the JSON conversion sets as UTC.

Luigi provided the following example of how to get the timezone diff:

console.log('-------------------------goService()');
var now = new Date();
var deltaUTC=now.getTimezoneOffset()_60_1000;
console.log("---------------- deltaUTC: "+deltaUTC);
var when = new Date(now.getTime() - deltaUTC + sdaVar.deltaMillSec);

    scheduler.setAlarm(    when,
    function(data) { displayResultRF(data) },
    function(data) { displayErrorRF(data) }
    );

     console.log("---------------- RF Alarm set: "+sdaVar.deltaMillSec);

Allow passing of parameters to alarm class

It would be useful to be able to pass parameters from the HTML/ JavaScript interface to the class that is actually started by the alarm.

As the class will be an activity and started by intent, we should be able to extend the current extras logic (used for ShowOption) to pass.

Need to research how there are passed to the HTML/ JavaScript app code.

How can I use scheduler.html as a view

I'm trying to apply this plugin into my ionic app.
As in instruction, I have to replaceany existing content node with: (add the content node if not already present)
==> in my case, I have to replace:
by :

Now I want to use Scheduler.html and scheduler.js as a View and a controller without replacing index.html with Schedule.html
How can I do that?
Thanks in advance.

Wake Up Phone

Does this plugin also work when my phone is in sleep mode. Suppose I have started my app and the user has kept the phone idle for some time and in the background I have an event raised in my app, will this plugin enable me to show my app on top of lock screen on android

Use setExact rather than set

Luigi raised concern over the accuracy. Asked to change:

am.set(AlarmManager.RTC_WAKEUP, when.getTime(), pi);
to become
am.setExact(AlarmManager.RTC_WAKEUP, when.getTime(), pi);

Need to just validate that this isn't going to cause any other issue. Might want to provide the ability for the developer to specify exact or not.

Plugin not working

I am trying to implement the plugin in my html file after I have installed the plugin. I use the following code:
var now = new Date().getTime();
var from_now = new Date(now + 60 * 1000);
cordova.plugins.scheduler.addAlarm('This is a test alarm', from_now, 'ShowOverLockScreen', null, function(data){ console.dir(data);}, function(data){ console.dir(data);} );

But I receive the error : Invalid Action in my console when running the application on an android phone.

[Suggestion] Success callback for addAlarm

I'd like to know the ids that are associated with the alarms that I add, as I add them. would it be possible to send output to the success callback of addAlarm so I can get the ids? The only property of an alarm that I can't access when adding it is it's ID as this is auto generated...

Debug warning: Could not find setExact

From my logcat at the beginning of the app starting:

03-31 21:03:59.961: I/dalvikvm(10218): Could not find method android.app.AlarmManager.setExact, referenced from method com.red_folder.phonegap.plugin.scheduler.SchedulerPlugin.addToAlarmManager
03-31 21:03:59.971: W/dalvikvm(10218): VFY: unable to resolve virtual method 35: Landroid/app/AlarmManager;.setExact (IJLandroid/app/PendingIntent;)V

On latest Cordova (4.2.0) and Android (3.6.4) app does not respect Single... launchmode

My app always worked properly: with singleTask launchmode:

  • if the app was closed, the scheduler would have started it and put in foreground
  • if the app was in background, the scheduler would have put in foreground
  • if the app was in foreground, it was staying in foreground

Now the problem is that if the app is closed BUT still in the android tasks list, then two instances get started...

Pretty sure it's not a plugin issue but despite many attempts I have no idea on how to overcome this...

Functions blocking main thread frequently

From my logcat when trying to call any js scheduler function:

when trying to cancel alarms:

  03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:2 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:3 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:4 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.311: I/Web Console(10218): ----------------------------------------------- Alarm:5 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.311: I/Web Console(10218): ----------------------------------------------- Alarm:6 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.321: I/Web Console(10218): ----------------------------------------------- Alarm:7 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.331: I/Web Console(10218): ----------------------------------------------- Alarm:9 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.331: I/Web Console(10218): ----------------------------------------------- Alarm:10 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.341: I/Web Console(10218): ----------------------------------------------- Alarm:12 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.351: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.351: I/Web Console(10218): ----------------------------------------------- Alarm:13 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.371: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.371: I/Web Console(10218): ----------------------------------------------- Alarm:14 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.391: I/Web Console(10218): ----------------------------------------------- Alarm:15 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.391: I/Web Console(10218): ----------------------------------------------- Alarm:19 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.421: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.421: I/Web Console(10218): ----------------------------------------------- Alarm:18 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.421: I/Web Console(10218): ----------------------------------------------- Alarm:21 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.431: I/Web Console(10218): ----------------------------------------------- Alarm:20 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.461: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 34ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.471: I/Web Console(10218): ----------------------------------------------- Alarm:22 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.492: I/Web Console(10218): ----------------------------------------------- Alarm:25 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.512: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 30ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.512: I/Web Console(10218): ----------------------------------------------- Alarm:24 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.532: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.542: I/Web Console(10218): ----------------------------------------------- Alarm:27 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.542: I/Web Console(10218): ----------------------------------------------- Alarm:29 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.562: I/Web Console(10218): ----------------------------------------------- Alarm:28 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.572: I/Web Console(10218): ----------------------------------------------- Alarm:31 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.642: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 67ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.642: I/Web Console(10218): ----------------------------------------------- Alarm:30 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.732: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 89ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.732: I/Web Console(10218): ----------------------------------------------- Alarm:34 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.752: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.762: I/Web Console(10218): ----------------------------------------------- Alarm:35 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.792: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 41ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.792: I/Web Console(10218): ----------------------------------------------- Alarm:32 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.822: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.822: I/Web Console(10218): ----------------------------------------------- Alarm:33 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.902: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 80ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.902: I/Web Console(10218): ----------------------------------------------- Alarm:38 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.932: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.942: I/Web Console(10218): ----------------------------------------------- Alarm:39 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.002: I/Web Console(10218): ----------------------------------------------- Alarm:36 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.062: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 61ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.102: I/Web Console(10218): ----------------------------------------------- Alarm:42 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.112: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 46ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.132: I/Web Console(10218): ----------------------------------------------- Alarm:43 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.222: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 105ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.322: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 46ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.342: I/Web Console(10218): ----------------------------------------------- Alarm:40 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.352: I/Web Console(10218): ----------------------------------------------- Alarm:41 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.412: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 85ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.453: I/Web Console(10218): ----------------------------------------------- Alarm:44 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.453: I/Web Console(10218): ----------------------------------------------- Alarm:45 at file:///android_asset/www/index.html:1413

When trying to add alarms:

    03-31 21:04:03.615: I/Web Console(10218): added alarm to fire @Mar 31, 9:16 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:03.675: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.755: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 69ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.875: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 39ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.905: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.945: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 26ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.995: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 52ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.995: I/Web Console(10218): added alarm to fire @Mar 31, 9:48 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.055: I/Web Console(10218): added alarm to fire @Mar 31, 10:12 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.095: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.145: I/Web Console(10218): added alarm to fire @Mar 31, 10:56 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.175: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 40ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.236: I/Web Console(10218): added alarm to fire @Mar 31, 11:15 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.356: I/Web Console(10218): added alarm to fire @Apr 1, 1:49 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.386: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.396: I/Web Console(10218): added alarm to fire @Mar 31, 11:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.426: I/Web Console(10218): added alarm to fire @Apr 1, 1:13 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.446: I/Web Console(10218): added alarm to fire @Apr 1, 12:22 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.506: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 56ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.516: I/Web Console(10218): added alarm to fire @Apr 1, 12:47 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.526: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.526: I/Web Console(10218): added alarm to fire @Apr 1, 3:16 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.586: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.586: I/Web Console(10218): added alarm to fire @Apr 1, 2:38 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.606: I/Web Console(10218): added alarm to fire @Apr 1, 2:11 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.676: I/Web Console(10218): added alarm to fire @Apr 1, 4:39 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.706: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 36ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.716: I/Web Console(10218): added alarm to fire @Apr 1, 4:07 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.756: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 26ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.756: I/Web Console(10218): added alarm to fire @Apr 1, 6:25 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.766: I/Web Console(10218): added alarm to fire @Apr 1, 6:52 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.776: I/Web Console(10218): added alarm to fire @Apr 1, 4:55 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.816: I/Web Console(10218): added alarm to fire @Apr 1, 5:25 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.856: I/Web Console(10218): added alarm to fire @Apr 1, 6:00 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.896: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 54ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.946: I/Web Console(10218): added alarm to fire @Apr 1, 3:45 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.956: I/Web Console(10218): added alarm to fire @Apr 1, 8:35 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.046: I/Web Console(10218): added alarm to fire @Apr 1, 7:16 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.046: I/Web Console(10218): added alarm to fire @Apr 1, 7:49 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.076: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.076: I/Web Console(10218): added alarm to fire @Apr 1, 9:04 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.096: I/Web Console(10218): added alarm to fire @Apr 1, 10:22 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.136: I/Web Console(10218): added alarm to fire @Apr 1, 9:39 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.166: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 45ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.207: I/Web Console(10218): added alarm to fire @Apr 1, 9:09 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.207: I/Web Console(10218): added alarm to fire @Apr 1, 10:53 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.257: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 56ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.257: I/Web Console(10218): added alarm to fire @Apr 1, 11:09 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.257: I/Web Console(10218): added alarm to fire @Apr 1, 12:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.287: I/Web Console(10218): added alarm to fire @Apr 1, 11:42 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.297: I/Web Console(10218): added alarm to fire @Apr 1, 1:16 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.357: I/Web Console(10218): added alarm to fire @Apr 1, 1:52 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.357: I/Web Console(10218): added alarm to fire @Apr 1, 2:31 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.567: I/Web Console(10218): added alarm to fire @Apr 1, 12:04 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 3:26 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 3:10 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 2:19 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 4:08 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 5:12 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 6:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.617: I/Web Console(10218): added alarm to fire @Apr 1, 4:21 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 5:57 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 5:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 6:52 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 8:31 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): alarmCount: 56 at file:///android_asset/www/index.html:1543

When trying to getAlarms():

    03-31 21:04:01.463: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 20ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.493: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 17ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.033: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 47ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.343: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.414: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 49ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.504: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.664: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 163ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.794: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.864: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.954: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.974: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.044: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.144: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.164: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.194: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.224: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.224: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.244: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.274: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.294: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.315: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416

I can't tell for certain, but it seems like when the main thread is blocked, that the corresponding function doesn't go through... I have a counter that increases everytime I make a call to my addAlarmAtTime(passedTime) function, and the number from the the counter is quite a bit higher than the length of alarms array that I get from getAlarms()...

For example, the counter is 56, when the length of the array that holds the alarms is only 37...

Show over lock screen

For Alarm like applications, we should be able to show the activity over the lock screen.

Examples of how to do this can be found:

Seems that it should just be the following code:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

I'd suspect that the Activity would need to be an explicit Activity for Lock Screen (something which just gives an turn off option). Likely to need to be a specific howto on the WIKI.

How can i call one function and stop the alarm

Now when the alarm is triggered my function is being called in a infinite loop ..
is there time limit in the alarm and how can i set it ??
Is there any way to store the id of alarm that is just made

cancelAll method to remove all alarms

Quick and dirty....

 function cancelAllAlarm(dataA) {
        for (var x in dataA) {
        console.log("----------------------------------------------- Alarm:"+dataA[x].id);
        scheduler.cancelAlarm( dataA[x].id,
            function(data) {
            scheduler.getAlarms(    function(dataA) { console.log("------ Alarm list:"+data) },
            function(data) { console.log("----- Scheduler cancel alarm" +dataA[x].id+" ok:"+data) });
            },
            function(data) { console.log("----- Scheduler cancel alarm"+dataA[x].id+" PROBLEM:"+data) }
        ); 
        };
    } 

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.