I am new in Android development. I am developing a twitter client. I would like to send a tweet at every morning at 8. I want to set the schedule like Alarm. How can I do that ? I will be happy if you point me to some examples or other resources. Thanks.
Here is an example of the AlarmManager:
private void daylyTask()
{
daylyBR = new BroadcastReceiver() {
@Override public void onReceive( Context context, Intent _ )
{
//Do something
Log.d(TAG, "daylyTask uitgevoerd.");
}
};
getApplicationContext().registerReceiver( daylyBR, new IntentFilter("yourApp.blah") );
daylyPendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 0, new Intent("yourApp.blah"), 0 );
GregorianCalendar cal = new GregorianCalendar();
cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
cal.set(GregorianCalendar.MINUTE, 0);
// set alarm to fire 5 sec (1000*5) from cal repeating every 86400000L ms (1 day)
manager.setRepeating( AlarmManager. RTC_WAKEUP, cal.getTimeInMillis() + 5000L, 86400000L, daylyPendingIntent );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With