I’ve declared a global variable class like this:
public class globalVar extends Application {
private String globalVar= "";
public String getGlobalVar() {
return globalVar;
}
public void setGlobalVar(String globalVar) {
this.globalVar = globalVar;
}
@Override
public void onCreate() {
//reinitialize variable
}
}
And declared it in my androidmanifest file like this:
<application android:name=".globalVar" android:icon="@drawable/icon"
android:label="@string/app_name"> </application>
And tried to set its value in a list under a onclicklistener:
((globalVar)getApplication()).setGlobalVar("something");
I’ve got it to work before in another application, but for some reason it’s giving me the source not found error…I’ve been scratching my heads off since this is my only obstacle now, has anyone experience this issue before or has an idea as to why I keep getting the error? Thanks!!
try getApplcationContext() instead of getApplication()