0

I have a service and some activity for that , I want whole application will restart at specific time like (03:00 pm), do you know any way to to do this , so at 3AM , the whole app restart ?

thanks

Ata
  • 10,914
  • 19
  • 53
  • 94
  • because of memory leaks , so users system do not be slow . every time my app starts , it makes some small memory . – Ata May 23 '12 at 16:15
  • 1
    Maby this can help you: http://stackoverflow.com/questions/4452565/start-app-at-a-specific-time – LukasFT May 23 '12 at 16:16
  • Why don't you just fix the memory leaks? :/ – Kevin Coppock May 23 '12 at 16:16
  • what you have try for this bez this is easy to start an service at specific time by using AlarmManager? – ρяσѕρєя K May 23 '12 at 16:18
  • @kcopp , it seem that there is a problem in android , why when I start activity and do nothing , and closing , it stores information and keep old used memories ??? – Ata May 23 '12 at 16:29
  • 1
    You should handle that during the lifecycle methods (onPause(), onDestroy(), etc.) I don't mean this rudely, but most likely the problem is not with Android but with your app. Restarting the app on a timer may WORK, but it's not the appropriate solution. Think for example what happens if a user is interacting with the application at 3:00 AM? Try to find what information is being stored after closing the app, and then from there find out *why* it is being stored, and from there, correct it. – Kevin Coppock May 23 '12 at 16:48
  • Kcopp , he should sleep at 3.00 AM , what he want from my app !:D – Ata May 23 '12 at 17:17

1 Answers1

0

You can use popular time based scheduler Cron found in unix/linux. by default it it is not active.need some hack inside. but i think you can use AlarmManager This is a system service.

AlarmManager myAlarmManager = Context.getSystemService(Context.ALARM_SERVICE).

And if you need to stay alive after system reboot . Then you have to schedule he alarm after the device reboots.And need to have the RECEIVE_BOOT_COMPLETED permission in your AndroidManifest.xml

Forhad
  • 1,038
  • 15
  • 26