java - Google Glass SimpleWeatherApp getCity function return null -


i'm trying re-adapt simple weather app (http://code.tutsplus.com/tutorials/create-a-weather-app-on-android--cms-21587) google glass, returns json object on android , works, in google glass when want use getcity function, have null pointer exception error.

my getcity function same 1 in simpleweatherapp

    public string getcity(){      return prefs.getstring("city", "jerusalem, il"); } 

theres 3 java files, 2 class , 1 activity.

citypreference , return city , city.

remotefetch json object

main activity build view google glass , show information need.

i can share whole project if want more informations.

here's part of mainactivity content private view buildview() { cardbuilder card = new cardbuilder(this, cardbuilder.layout.text); card.settext(r.string.open_weather_maps_app_id); //updateweatherdata(new citypreference(getactivity()).getcity());

    updateweatherdata(new citypreference().getcity());        return card.getview(); }   private void updateweatherdata(final string city){     new thread(){         public void run(){             final jsonobject json = remotefetch.getjson(mainactivity.this.getapplicationcontext(),city);             if(json == null){                 handler.post(new runnable(){                     public void run(){                         toast.maketext(mainactivity.this,                                 mainactivity.this.getstring(r.string.place_not_found), = json null                                 toast.length_long).show();                     }                 });             } else {                 handler.post(new runnable(){                     public void run(){                         renderweather(json);                     }                 });             }         }     }.start(); } 

so that's mean json object null. remotefetch.java can find in simpleweatherapp link on top of post

modify code under

public string getcity(){      if(prefs != null)         return prefs.getstring("city", "jerusalem, il");      return "city_not_initialized"; } 

or share more code


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -