android - Global variable becomes null sometimes -


i have variable declared in base base extends application.

the variable static , able set , access fine. on devices null sometimes.

public class application extends android.app.application {  public static arraylist<string> nextpage;   @override public void oncreate() {     super.oncreate();       ...     } } 

 

<application             android:name="application"             android:allowbackup="true"             android:icon="@drawable/ic_launcher"             android:label="@string/app_name"             android:theme="@style/theme.mytheme" >       ... 

i referencing this: application.nextpage

i using bug sense , see there have been 30 errors variable null. happens rarely, because app gets thousands of users per day , error has occured 30 times week.

is aware of such issue or might causing it?

problem devices:

sch-i605 19%     3 sm-n900p 13%     2 st26i 13%        2 samsung-sgh-i337 13% 2 shv-e210s 13%    2 droid razr hd 13%    2 sch-i200 13%     2 droid razr 7%    1 

problem occurred on following sdk:

4.1.2 40%    12 4.3 30%      9 4.4.2 10%    3 4.1.1 7%     2 4.2.2 7%     2 4.0.3 4%     1 2.3.6 4%     1 

where in app initialize nextpage?

i recommend adding nextpage = new arraylist<string>(); in oncreate of application, or directly in field variable.

if initialize nextpage in activity, possible scenario of null be:

  • app starts
  • activity starts - nextpage set , valid
  • user leaves app
  • android destroys app (possibly after time)
  • a broadcast sent (if have defined broadcast listening in manifest)
  • app started (but not activity)
  • the nextpage list null

not knowing how app working, thought example indication of problem.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -