Cordial greeting,
I have these global variables in a java class:
package com.windroid.dinas;
import android.app.Application;
public class GlobalVariables extends Application {
private String Name;
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
private String Usr;
public String getUsr() {
return Usr;
}
public void setUsr(String usr) {
Usr = usr;
}
}
And this is my fragment:
package com.windroid.dinas;
import ...
public class PedidoFragment extends Fragment{
final static String urlAddress="http://10.0.3.2/baradm/ubica.php?id=";
GlobalVariables globalVariables;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_pedido, container, false);
final Spinner spinnerUbica = (Spinner) view.findViewById(R.id.spUbica);
/* <--- urlAddress+globalvariables.getUsr() --->*/
new Downloader(getActivity(),urlAddress,spinnerUbica).execute();
return view;
}
}
And I need the part:
new Downloader(getActivity(),urlAddress,spinnerUbica).execute();
something like this will remain:
new Downloader(getActivity(),urlAddress+globalvariables.getUsr(),spinnerUbica).execute();
But the variable getUsr gives null, but from other activities if it has an assigned value. What should I do to access the value saved in this variable?