1

Are there any possibilities to make an app to restart by itself after 60 seconds of inactivity of the Android phone?

This is what I tried:

public class BootUpReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent i = new Intent(context, SplashScreen.class);
        PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.cancel(pi); // cancel any existing alarms
        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() +60000,
            AlarmManager.INTERVAL_DAY, pi);


    }

} 

but is not working.

Gabrielle
  • 4,933
  • 13
  • 62
  • 122
  • check this. You can obtain an idea of autostart application http://stackoverflow.com/questions/1056570/how-to-autostart-an-android-application – mobileDeveloper Nov 24 '11 at 12:15

2 Answers2

4

yes use a Alarm manager to wake it up... you can use the alarm manager in the background service or something and then make the app to open.

medampudi
  • 399
  • 3
  • 15
  • 1
    can you provide me an example? – Gabrielle Nov 24 '11 at 13:21
  • [link](http://stackoverflow.com/q/4739222/696145) this is the example the user does not want what you want... so be guided by the question.. if you want i will do a little more in depth working with you on the scenario needed specifically by you but i need to know more about the requirments and things like that... – medampudi Nov 24 '11 at 13:27
1

you can also takes benefit of Async Class

http://labs.makemachine.net/2010/05/android-asynctask-example/

in onPostExecute you can do as u want.

Last Warrior
  • 1,307
  • 1
  • 11
  • 20