TiGer TiGer - 5 days ago 4x
Android Question

Start app at a specific time

I was wondering if it's possible (and if it is how) to start up my app at a specific time, something like an alarmclock which goes off at a specific time.
Let's say I want my app to start up at 8 in the morning, is that feasable ?


You can do it with AlarmManager, heres a short example. First you need to set the alarm:

        AlarmManager am = (AlarmManager) con

    Date futureDate = new Date(new Date().getTime() + 86400000);


    Intent intent = new Intent(con, MyAppReciever.class);

    PendingIntent sender = PendingIntent.getBroadcast(con, 0, intent,

    am.set(AlarmManager.RTC_WAKEUP, futureDate.getTimeInMillis(), sender); 

Next, You need to create a reciever with some code to execute your application: (ie- starting your app):

public class MyAppReciever extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {

    startActivity(new Intent(context, MyAppMainActivity.class));