解析android getInBackground函数没有运行

时间:2013-10-10 07:46:10

标签: java android android-asynctask parse-platform

任何人都可以帮我解释为什么函数getInBackground没有运行我想从android中的parse中获取数据。 这是我的类,它在fetchData(String themeId)

中调用parseManipulate的函数
public class selectTheme extends Activity implements OnClickListener{

Button gBtn;
Button rBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.themeselection);

    String themeid = "ECGo4oSKgU";
    ParseManipulate pm = new ParseManipulate();

    pm.fetchData(themeid);


/*      gBtn = (Button)findViewById(R.id.greentheme);
    rBtn = (Button)findViewById(R.id.redtheme);

    gBtn.setOnClickListener(this);
    rBtn.setOnClickListener(this);
*/  
}

这是我在ParseManipulate类中的fetchData()函数。编译器不运行函数getInBackground()函数并跳转到函数结束括号

public class ParseManipulate {

    public void fetchData(String ThemeId)
    {

    ParseQuery<ParseObject> pq = ParseQuery.getQuery("testThemes");

    pq.getInBackground(ThemeId, new GetCallback<ParseObject>(){

        @Override
        public void done(ParseObject object, ParseException e) {
            // TODO Auto-generated method stub
            if(e == null)
            {
            //  value = object.getString("ThemeName");
                Log.d("ParseObject", ""+object.getString("ThemeName"));
            }
            else
            {
            //  Toast.makeText(getApplicationContext(), "error in data fetching", Toast.LENGTH_SHORT).show();
            }
        }

    });
    }
}

1 个答案:

答案 0 :(得分:0)

Instead of      

 Log.d("ParseObject", ""+object.getString("ThemeName"));

像这样使用

Log.d("ParseObject", ""+object.fetchIfNeeded().getString("ThemeName"));