我收到了用户的错误报告,我不知道我的代码有什么问题。 logcat是这样的:
java.lang.NullPointerException
at com.laurenswuyts.find.it.MainActivity$LoadPlaces$1.run(MainActivity.java:299)
at android.app.Activity.runOnUiThread(Activity.java:4244)
at com.laurenswuyts.find.it.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:293)
at com.laurenswuyts.find.it.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:602)
at android.os.AsyncTask.access$600(AsyncTask.java:156)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
这是关于这段代码:
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed Places into LISTVIEW
* */
// Get json response status
String status = nearPlaces.status;
// Check for all possible status
if(status.equals("OK")){
// Successfully got places details
if (nearPlaces.results != null) {
// loop through each place
for (Place p : nearPlaces.results) {
任何人都可以帮助我吗?我真的被困在这个......
答案 0 :(得分:1)
日志告诉你
(MainActivity.java:299)
这意味着MainActivity的第299行
这一行是:
String status = nearPlaces.status;
这只是意味着nearPlaces为null ......我们无法做更多的事情来解决这个问题; - )
你应该用一些数据初始化它!