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. Showing Progress status for Multiple items exactly like Downloading in Mozilla Firefox

HI all,
I have a problem ,please guide me.

I want to download multiple files at a time ,the situation is in one
activity the use clicks download the file ,then i am forwarding to the
activity where i am downloading using async task  and showing the
downloading status in horizontal progress bar.

It is working fine for single file download.
If user selects multiple downloads ,i have to show the progress status
of the two items.

Totally ,i have situation like how it happens downloading in  Mozilla
Firefox browser.

I have tried many ways,but i didn't get solved.Please help me.

-- 

2. Get responce from the UDP server

Hi All,

   I am new in Android, I need to get responce from the UDP server
using the Intent method.

Is there a way to get the data using Intent?

Thanks
Remo

-- 

3. Listing ROM apps

4. Provide the security for SDCARD files

5. Android application upgrade scenario

6. MapActivity (MapView) Problem

7. USB Host Support (USB mass storage)