Search code examples
androidautostart

How can I play the song in specific time on Android?


I need to play the song from memory card in the specific time like 10am, 1pm and 5pm. So here my questions are, How to auto start the application? and How to play that songs in regular intervals?


Solution

  • Please check put android's AlarmManager, http://developer.android.com/reference/android/app/AlarmManager.html

    It a nutshell, you will create an alarm for a particular time, register a BroadcastReceiver to be called in response to the alarm going off. In the receiver, you will start an IntentService that will use MediaPlayer to play the song, and again use AlarmManager to schedule another alarm for the next time you want to play the song.

    http://developer.android.com/reference/android/content/BroadcastReceiver.html http://developer.android.com/reference/android/app/IntentService.html http://developer.android.com/reference/android/media/MediaPlayer.html

    There are lots of nuances to getting it right, and explaining them is not in the scope of this answer. If you Google on the topic, you will find lots of examples and tutorials.