Help With AlarmManager Please?

by Tommy » Wed, 21 Jul 2010 01:55:43 GMT


Sponsored Links
 Hi everyone,

I am currently setting an alarm to fire off a background service every
2 minutes in order to check my server for certain updates. Now if I
start the app and my screen is on and not locked the phone plays the
sound I need it to play and opens the activity. Thats great. But the
way I need it to happen is if the screen is off and the phone locked I
still need it to check every two minutes and I need it to play that
sound and open the activity that is needed. This does not happen for
some reason. Could someone explain to me why the alarm doesn't
function when my app is not "running" (by this i mean the app is
marked as a running process but not actually visible to the user) and
the screen is off? The code for the timer is below:

int alarmType = AlarmManager.RTC_WAKEUP;
                        long timeToRefresh = System.currentTimeMillis() + (120 
* 1000);
                        alarm.set(alarmType, timeToRefresh, alarmIntent);


The intent code after I set the alarm:
if(validAlert == true){
                                Intent startIntent = new Intent(this, 
SevereAlert.class);
                                
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                startActivity(startIntent);

                        }

I set valid alert a little above.

Once the intent gets called to open it is suppose to play a sound and
display a listview which like I said works correctly if I start the
service from my app but doesn't do a darn thing if the screen is not
on.

Thank you for your help and your time,

Tommy

--



Help With AlarmManager Please?

by Tommy » Wed, 21 Jul 2010 03:13:41 GMT


 AH-HA after a little more digging and research into alarm manager I found
out I wasn't setting the wakelock! 

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Tommy
Sent: Tuesday, July 20, 2010 1:55 PM
To: Android Developers
Subject: [android-developers] Help With AlarmManager Please?

Hi everyone,

I am currently setting an alarm to fire off a background service every
2 minutes in order to check my server for certain updates. Now if I
start the app and my screen is on and not locked the phone plays the
sound I need it to play and opens the activity. Thats great. But the
way I need it to happen is if the screen is off and the phone locked I
still need it to check every two minutes and I need it to play that
sound and open the activity that is needed. This does not happen for
some reason. Could someone explain to me why the alarm doesn't
function when my app is not "running" (by this i mean the app is
marked as a running process but not actually visible to the user) and
the screen is off? The code for the timer is below:

int alarmType = AlarmManager.RTC_WAKEUP;
                        long timeToRefresh = System.currentTimeMillis() +
(120 * 1000);
                        alarm.set(alarmType, timeToRefresh, alarmIntent);


The intent code after I set the alarm:
if(validAlert == true){
                                Intent startIntent = new Intent(this,
SevereAlert.class);
        
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                startActivity(startIntent);

                        }

I set valid alert a little above.

Once the intent gets called to open it is suppose to play a sound and
display a listview which like I said works correctly if I start the
service from my app but doesn't do a darn thing if the screen is not
on.

Thank you for your help and your time,

Tommy

--


Sponsored Links


Help With AlarmManager Please?

by Kostya Vasilyev » Wed, 21 Jul 2010 03:27:55 GMT


 Tommy,

You are not going to hold the wakelock the entire time the phone is 
asleep, are you? That would drain the battery pretty fast.


Your alarm already wakes the application up, hopefully you can hold the 
wake lock just for the duration of whatever periodic task the app needs 
to perform.


-- Kostya

20.07.2010 23:12, Tommy :
AH-HA after a little more digging and research into alarm manager I found out I wasn't setting the wakelock! -----Original Message----- From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of Tommy Sent: Tuesday, July 20, 2010 1:55 PM To: Android Developers Subject: [android-developers] Help With AlarmManager Please? Hi everyone, I am currently setting an alarm to fire off a background service every 2 minutes in order to check my server for certain updates. Now if I start the app and my screen is on and not locked the phone plays the sound I need it to play and opens the activity. Thats great. But the way I need it to happen is if the screen is off and the phone locked I still need it to check every two minutes and I need it to play that sound and open the activity that is needed. This does not happen for some reason. Could someone explain to me why the alarm doesn't function when my app is not "running" (by this i mean the app is marked as a running process but not actually visible to the user) and the screen is off? The code for the timer is below: int alarmType = AlarmManager.RTC_WAKEUP; long timeToRefresh = System.currentTimeMillis() + (120 * 1000); alarm.set(alarmType, timeToRefresh, alarmIntent); The intent code after I set the alarm: if(validAlert == true){ Intent startIntent = new Intent(this, SevereAlert.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); } I set valid alert a little above. Once the intent gets called to open it is suppose to play a sound and display a listview which like I said works correctly if I start the service from my app but doesn't do a darn thing if the screen is not on. Thank you for your help and your time, Tommy
-- Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com --



Help With AlarmManager Please?

by Tommy » Wed, 21 Jul 2010 03:53:32 GMT


 Yeah I figured out how to hold the wake only if I need to notify the user. It 
seems everything worked w/o a wake lock except updated my listview and playing 
the sound. So once if I have to go into the activity I start the wakelock 
otherwise nothing happens. Thanks for the reply!

-----Original Message-----
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Kostya Vasilyev
Sent: Tuesday, July 20, 2010 3:28 PM
To: android-developers@googlegroups.com
Subject: Re: [android-developers] Help With AlarmManager Please?

Tommy,

You are not going to hold the wakelock the entire time the phone is 
asleep, are you? That would drain the battery pretty fast.

Your alarm already wakes the application up, hopefully you can hold the 
wake lock just for the duration of whatever periodic task the app needs 
to perform.

-- Kostya

20.07.2010 23:12, Tommy :


-- 
Kostya Vasilev -- WiFi Manager + pretty widget --  http://kmansoft.wordpress.com 

--



Other Threads

1. Activation service

Hi All,

in my setting, when i activate the service, its activated. and when i
deactivate, its deactivated.
But after activation, how can i  know if service is running or not. is there
any condition for checking?
Please suggest me . or give any related materials or coding in that.

Thanks in advance,

Dolan.

--~--~---------~--~----~------------~-------~--~----~

2. problem on running applications on android on arm board

Hi,

         I run the android on the arm board. I have some applications of
android.I am unable to the applications on my arm board.I want to run my
applications on my arm board. Please tell the procedure for running the
applications on the arm board.



Thanks and regards,
Srikanth.

--~--~---------~--~----~------------~-------~--~----~

3. How can I use NFS?

4. How to add element in spinner?

5. changing the default menu style

6. Mobile 3D Virtul World service on Android Platform!

7. Changing the selection path of a ListActivity