The answer of my question is probably out there but I not sure I understand the concept correctly.
I've a small Json file, which contains only
{"meteo": "1"}
I can successfully read it with Gson and show it my a Toast.
But If a do an "if statement" based on it like this:
if(meteoStatus == "1"){ // I know for sure it's 1
// Do something
} else {
// Do something else
}
It always goes to the second part of the if statement despite I have done a toast just before which show me a 1
Here is the complete section of code:
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String url = "http://www.boisdelacambre.be/ios/json/weather.php?key=53666d6c7b206a532d52403e414d2579";
String result = getUrlContents(url);
gsonInstance = new Gson();
meteo = new Meteo();
meteo = gsonInstance.fromJson(result, meteo.getClass());
String meteoStatus = meteo.getMeteo();
View rootView = inflater.inflate(R.layout.fragment_meteo, container, false);
ImageWeather = (ImageView) rootView.findViewById(R.id.imageWeather);
DonnesOuRemis = (TextView) rootView.findViewById(R.id.donnesOuRemis);
Toast.makeText(getActivity(), meteoStatus, Toast.LENGTH_LONG).show();
if(meteoStatus == "1"){
// il fait beau
Toast.makeText(getActivity(), "Pas remis !!", Toast.LENGTH_LONG).show();
ImageWeather.setImageResource(R.drawable.soleil);
DonnesOuRemis.setText("Donnés");
DonnesOuRemis.setTextColor(Color.parseColor("#06f828"));
} else {
Toast.makeText(getActivity(), "Pourquoi remis ??", Toast.LENGTH_LONG).show();
ImageWeather.setImageResource(R.drawable.pluie);
DonnesOuRemis.setText("Remis");
DonnesOuRemis.setTextColor(Color.parseColor("#f80b27"));
}
Any help will be highly appreciated ;-)