У меня есть метод, который возвращает широту местоположения
public double[] getlat(){
double lat[]=new double[20];
JSONObject json = JSONFunction.getJSONfromURL("https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=1000&types=bank&sensor=true&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
try{
JSONArray JArray = json.getJSONArray("results");
Log.v(TAG, "getting results");
for(int i=0;i<JArray.length();i++){
JSONObject e = JArray.getJSONObject(i);
JSONObject location=e.getJSONObject("geometry").getJSONObject("location");
lat[i] = location.getDouble("lat");
}catch(JSONException e) {
Log.e("log_tag", "Error parsing data "+e.toString());
}
return lat;
}
Я получил этот массив в основной активности как
public class Test extends Activity {
private static final String TAG = "test";
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle icicle) {
// Be sure to call the super class.
super.onCreate(icicle);
StringBuilder sb =new StringBuilder();
double a[]=getlat();
for(int i=0;i<a.length;i++) {
sb.append(a[i]+"\n");
}
TextView tv=(TextView)findViewById(R.id.text);
tv.setText(sb);
}
Предоставление мне исключения nullpointorно в logcat я могу видеть отображаемый массив широты. Проблема в возврате лат.Поправь меня, где я не прав ..