Git Product home page Git Product logo

Comments (7)

benbahrenburg avatar benbahrenburg commented on August 21, 2024

It is currently working in my projects, but with Android there could be many factors at play here. Could you check what DDMS says when you run you code. It should print the reminder frequency in milliseconds to the window.

If you send me a sample of what you are trying to run I'll take a look at it next weekend. If possible please post to gist so I can put some tests around it.

from bencoding.alarmmanager.

benbahrenburg avatar benbahrenburg commented on August 21, 2024

Hello,

I was able to do some testing around this and it is working. You might be having an issue with it waking up the device so I pushed an update with the RTC_WAKEUP set to help avoid this.

Please note the following:

  1. If your service is already running, it won't run again as the Alarm Manager simply makes sure it is running. In the future you'll be able to create an interval service but at the current time I don't have a need for this feature. If you look in AlarmServiceListener there is an example on how to set an interval.
  2. The switch to RTC_WAKEUP helps in many scenarios but so have a few side effects. I'm not sure how you are implementing your timer functions but please be aware this will have an impact.

The easiest way to test is to use the sample project and DDMS. If you load the sample project, and press the #6 button you will see a few things. First it will launch the service after about 2 minutes. Then approx. each minute you will see the message "Service is already running no need for us to start".

If you don't see the messages you'll want to make sure you have the service name correct. To check this open your AndroidManifest.xml file in your build/android directory. You need to make sure the service name provided in the correct service name in your AndroidManifest.xml. For example the sample app passes in a service name of com.appworkbench.alarmtest.TestserviceService and you can see this within the AndroidManifest.xml as

<service android:name="com.appworkbench.alarmtest.TestserviceService"/>

Hope this helps. If you have any more questions please feel free to re-open the issue.

from bencoding.alarmmanager.

seismicsix avatar seismicsix commented on August 21, 2024

Hi,

OK, So I tried your new Example. and now I can get the repeat service to fire... however it only fires once?

var btn6 = Ti.UI.createButton({
title:"Alarm & Service Basic Repeat", top:180, right:5, width: 150, height:75
});
win.add(btn6);
btn6.addEventListener('click',function(e){
alarmManager.addAlarmService({
    //The full name for the service to be called. Find this in your AndroidManifest.xml Titanium creates
    service:'com.appworkbench.alarmtest.TestserviceService', 
    minute:1, //Set the number of minutes until the alarm should go off
    repeat:60000 //You can use the words hourly,daily,weekly,monthly,yearly or you can provide milliseconds.
    //Or as shown above you can provide the millesecond value 
}); 
var ew = Ti.UI.createAlertDialog({
    title:'Info', message:"The Service provided will be started in about 2 minutes & repeat each minute",
    buttonNames:[Ti.Android.currentActivity.getString(Ti.Android.R.string.ok)]
});
    ew.show();      
});

The debug outputs:

[WARN][TiJSIntervalService(  335)] (main) [16,63841] The intent is missing the extra value 'interval', therefore the code will be executed only once.
[INFO][TiAPI   (  335)] Test Service!!!!!!
[INFO][ALERT   (  335)] (KrollRuntimeThread) [696,64538] Hello from the test service

from bencoding.alarmmanager.

benbahrenburg avatar benbahrenburg commented on August 21, 2024

If you open DDMS you'll see that after 2 minutes it will tell you that "Service is already running no need for us to start".

When I designed the module, my thought was this would just be a bridge into Titanium. If you want to use the module to re-execute the service code on the timed frequency you will need to stop the service within Titanium.

Here is a link to the Titanium documentation around how to do this.
http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Android.Service

When I add in the sound option, I'll also provide a parameter to force a restart. I'll try to get a new build out this evening, but will have it available no later then June 9th ( in case I don't get time this weekend ).

from bencoding.alarmmanager.

seismicsix avatar seismicsix commented on August 21, 2024

Hi,

Thanks for explaining, it all makes sense now, and I did indeed get it working how I wanted by adding...

var service = Titanium.Android.currentService;
var intent = service.intent;
Ti.Android.stopService(intent);

To the testservice.js file. Thought I would post in case it could help someone else.

from bencoding.alarmmanager.

benbahrenburg avatar benbahrenburg commented on August 21, 2024

I just added an option called forceRestart that will kill your service and restart it if it is already running.

Additionally there is a new parameter called interval that allows you to create an interval service.

from bencoding.alarmmanager.

MahmoudElmoghazy avatar MahmoudElmoghazy commented on August 21, 2024

Hi benbahrenburg how are u ?
now i have an issus i hope u help me when i close my mobile device the application notfications service stop what can i do with this issus could u help me ?

from bencoding.alarmmanager.

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.