java - Change value of variable? -


i have variable application class. want change value of variable (which originates application class) activity. right now, can create instance of variable, , change value of instance, defeats whole purpose of creating variable application class (so can used throughout activities in project)

here variable. long, , represents number of activities have passed by:

enter image description here

i trying change value of numberofactivities every activity trying this:

((activitycount) getapplicationcontext()).numberofactivities++;

as can see here, changing instance of it. when try access variable later, value 0. shouldn't case, have declared static. popup comes when hover on line saying static member accessed via instance reference. how can change value of variable separate activity?

thank much, , if need more information, feel free let me know. feedback appreciated.

thanks!

by doing this:

currenttime = ((mycurrenttime) getapplicationcontext()).currenttime;

you erase value of local currenttime static 1 initialised @ 0.

try doing other way around:

((mycurrenttime) getapplicationcontext()).currenttime = currenttime;


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -