如果我有以下功能:
public class Product {
public String barCode;
public String name;
public Category category;
public double price;
public Store store;
WebService ws = new WebService();
public product getProduct(String barcode) {
final Product p = new Product();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Product");
query.getInBackground("XxfqN425pK", new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
Log.d("((((( name )))))", name);
String name1 = "p=" + object.getString("product_name");
p.name = name1;
} else {
p.name = "erro" + e.getMessage();
}
}
});
return p;
}
public Product get() {
return this;
}
}
p.name
来自getProduct()
调用的Log
始终为空,尽管@Override
protected Product doInBackground(Void... arg0) {
Product p = new Product();
return p.getProduct("");
}
@Override
protected void onPostExecute(Product result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Log.d("Product name >>>", result.name + "--");
}
语句显示名称的值
在哪里调用函数:
class getProduct扩展了AsyncTask {
{{1}}
}