I got an Activity class that uses two other classes; one of them extending ImageView and one that extends BaseAdapter like so:
My ImageView class does some progresses when it is called and when I am starting it for the first time it does what I want it to. This is also the case if I press home button and then resumes. But for some reason it does not work if I resume from standby mode. (pressing the button on the phone that makes the screen dark) When I unlock the phone it crashes. It crashes on a nullPointerException, and from what I can read when I try to call getChildAt() on a GridView defined by the BaseAdapter.
Is it any way to make the app do the same as when I press the home button, as when I set the phone in standby mode? EDIT:
public MyCustomDefinedImageViewClass (Context context) {
super (context);
mContext = context;
MyCustomDefinedImageViewClass someThing =(MyCustomDefinedImageViewClass)gridViewIGetTheChildFrom.getChildAt(some int);
} This is what is causing my crash:
11-19 22:00:48.200: E/AndroidRuntime(6252): at my.package.name.MyCustomDefinedImageViewClass.<init>(MyCustomDefinedImageViewClass.java:57)
I do not think the code is helping to much and that was why I did not post it in the first place.
Try adding
to your manifest file. The crash is a result of activity restart when the lock screen comes up. The lock screen forces portrait orientation and if you are not ready to handle it then your app may crash.
If that doesn't do it, try overriding onRetainNonConfigurationInstance().
See this post for info on how to retain objects: How to save lot of object in onRetainNonConfigurationInstance() in android
Also read this android-group thread for understanding what happens when device goes to sleep.