Android 解析未接收的对象

Android 解析未接收的对象,android,parse-platform,Android,Parse Platform,我从以前的活动中获取解析对象的Id,并将其存储在obj中 我知道Id是通过检查传递的,但是我得到了空指针异常,因为我的四个字符串restName、restAddress、restcoine和restLocation是空的,即使在我尝试通过解析查询分配相应的值之后也是空的 package com.example.gastronomaapp; import android.content.Intent; import android.os.Bundle; import android.suppor

我从以前的活动中获取解析对象的Id,并将其存储在obj中 我知道Id是通过检查传递的,但是我得到了空指针异常,因为我的四个字符串restName、restAddress、restcoine和restLocation是空的,即使在我尝试通过解析查询分配相应的值之后也是空的

package com.example.gastronomaapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public class SingleRestraunt extends ActionBarActivity {
    private GoogleMap map;
    TextView resteName, resteCuisine, resteLocation, resteAddress;
    String restName = "nothing", obj, restCuisine = "nothing",
            restLocation = "nothing", restAddress = "nothing";
    Double Lang, Long;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_single_restraunt);

        Intent i = getIntent();
        obj = i.getStringExtra("restName");
        getDetails(obj);

    }

    private void getDetails(String obj) {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Restraunt");
        query.getInBackground(obj, new GetCallback<ParseObject>() {
            @Override
            public void done(ParseObject object, ParseException e) {
                if (e == null) {
                    restName = object.getString("Name");
                    restCuisine = object.getString("Cuisine");
                    restLocation = object.getString("Location");
                    restAddress = object.getString("Address");
                    Lang = object.getDouble("Lat");
                    Long = object.getDouble("Long");
                } else {
                    e.printStackTrace();
                }
            }
        });
        // prepareMap(Lang, Long);
        addData();

    }

    public void addData() {
        resteName = (TextView) findViewById(R.id.restrauntName);
        resteCuisine = (TextView) findViewById(R.id.restrauntCuisine);
        resteLocation = (TextView) findViewById(R.id.restrauntLocation);
        resteAddress = (TextView) findViewById(R.id.restrauntAddress);
        resteName.setText(restName);
        resteCuisine.setText(restCuisine);
        resteLocation.setText(restLocation);
        resteAddress.setText(restAddress);
    }

    public void prepareMap(Double Lang, Double Long) {
        final LatLng REST = new LatLng(Lang, Long);
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
        @SuppressWarnings("unused")
        Marker hamburg = map.addMarker(new MarkerOptions().position(REST)
                .title("Here"));
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(REST, 15));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.single_restraunt, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void Submit(View v) {
        final EditText edit = (EditText) findViewById(R.id.review);
        final EditText edit1 = (EditText) findViewById(R.id.rName);
        String rName = edit1.getText().toString();
        String review = edit.getText().toString();

        ParseObject newReview = new ParseObject("Reviews");
        newReview.put("Name", rName);
        newReview.put("review", review);
        newReview.saveInBackground();
    }
}

最初,我将nothing值添加到所有字符串以进行调试。当快速运行时,会打印nothing,表示查询没有对我的字符串进行任何更改。有什么建议吗?

您是否初始化了解析?e、 g Parse.initializethis,Init.Parse_APPLICATION_ID,Init.Parse_CLIENT_ID;PushService.setDefaultPushCallbackthis,Splash.class;ParseInstallation.getCurrentInstallation;是的,我有,解析调用似乎在另一个活动中工作,而不是在这个活动中。我越来越好奇,我是否使用了正确的目标尝试了你的建议,但它没有解决我的问题。还有其他建议吗?第一个问题,您是否更新了PARSE SDK?或者创建一个扩展应用程序的类。第二,解析中的列Lat和Long的类型是什么?