Prevent app from being destroyed when android goes into sleep mode


Last Updated:

  1. id0001

    id0001 Well-Known Member This Topic's Starter

    Joined:
    Apr 20, 2010
    Messages:
    142
    Likes Received:
    23
    I am developing some sort of web image viewer which gets a list of images from the web and shows it to the user.

    My problem is that when android goes into sleep mode by waiting for the screen to turn black or by pressing the powerbutton, my app gets destroyed and reloads when android awakens again. It is then reset and needs to reload all the images I downloaded earlier.

    When I download the images I put them in the cache and add a string id to a buffer class so the app can download images async in the background and the user can quickly navigate through images.

    Is there a way to prevent my app from being destroyed when android goes to sleep mode?

    Thanks in advance.
     

    Advertisement
  2. mikech

    mikech New Member

    Joined:
    Jun 11, 2010
    Messages:
    1
    Likes Received:
    0
    Hi,
    I'm brand new to coding on Android and in general, but I've been reading the docs for the past several hours and I think this is the answer to your problem. I'm not sure if it works on sleep, but it sounds like it should:

    Application Fundamentals | Android Developers

     
  3. id0001

    id0001 Well-Known Member This Topic's Starter

    Joined:
    Apr 20, 2010
    Messages:
    142
    Likes Received:
    23
    I've just tried it but it didn't work. It still destroys and reloads my activity.
     

Share This Page

Loading...