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. Running application on Dell Streak emulator

Hi All,

I need to run my application on Dell streak, I am not able to find out
any emulator to test it. My application is working good on 2.2
emulator but on Dell Streak, application is not occupying complete
screen and some portion of the screen is appearing as black.

I am not able to reproduce same thing on 2.2 emulator.

If someone know any emualtor specific to Dell Streak or some other way
to test application for Dell Streak, then please let me know.

Thanks & Regards,
Manish

-- 

2. How declare in AndroidManifest when one application have two packages

Dear all,

I have two packages "com.android.one" and "com.android.two". the first
package have on activity, and package two have an activity name for
activityA

AndroidManifest.xml following
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.one">
......
......

    <activity android:name="com.android.two.activityA"></activity>
.....
.....


My code following

ComponentName componentName = new ComponentName("com.android.two",
"com.android.two.activityA");

Intent intent=new Intent();
intent.setComponent(componentName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);


Error log following

03-03 20:10:17.217: ERROR/HelloYoumi(16917): Unable to find explicit
activity class {com.android.two/com.android.two.activityA}; have you
declared this activity in your AndroidManifest.xml?
03-03 20:10:17.217: INFO/ActivityManager(202): Starting: Intent {
flg=0x10000000 cmp=com.android.two/.activityA } from pid 16917

So, it seams error declared in AndroidManifest.xml, How can i declare
in AndroidManifest.xml?

-- 

3. Notification from database

4. CTS in android

5. is there a way to programmatically restart acore via adb shell after it's crashed?

6. Application icon missing

7. pen source XMPP client for android