Tuesday, April 30, 2013

Re: [android-developers] Re: Running a song after every one hour..

Maybe this will help? 

// Get a reference to the Alarm Manager 
AlarmManager alarmManager = (AlarmManager) getSystemService( Context.ALARM_SERVICE); 
// Set the alarm to wake the device if sleeping. 
int alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP; 

// Schedule the alarm to repeat every half hour. 

long timeOrLengthofWait = AlarmManager.INTERVAL_HALF_HOUR; 

// Create a Pending Intent that will broadcast and action 
String ALARM_ACTION = "ALARM_ACTION"; 
Intent intentToFire = new Intent( ALARM_ACTION); 
PendingIntent alarmIntent = PendingIntent.getBroadcast( this, 0, intentToFire, 0); 

// Wake up the device to fire an alarm in half an hour, and every 
// half-hour after that. 

alarmManager.setInexactRepeating( alarmType, timeOrLengthofWait, timeOrLengthofWait, alarmIntent);

Meier, Reto (2012-04-05). Professional Android 4 Application Development (Wrox Professional Guides) (Kindle Locations 9250-9257). John Wiley and Sons. Kindle Edition. 




On Tuesday, April 30, 2013 9:58:19 AM UTC-5, Ravi Tewari wrote:
Thanks Piren.. Will look at it... But I was looking if someone already has done similar


On Tue, Apr 30, 2013 at 8:23 PM, Piren <gpi...@gmail.com> wrote:
http://developer.android.com/reference/android/content/Intent.html#ACTION_BOOT_COMPLETED

Figure it out :)


On Tuesday, April 30, 2013 5:40:59 PM UTC+3, Ravi Tewari wrote:
 
I need to create an app that will play a song after every one hour. The app will be running all the times but in background. As soon as it is 9 o'clock, it will play a song. Once song is over, app should go idle. Again as soon as it is 10 o'clock, it will again play that song. So on for 365*24*7... Even after boot up the device, the app should get started automatically.
 
So is this possible, if yes, can you help/guide me in this?
Appreciate your response !
 
Peaceful time ahead...
 
 

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment