Android 无法通过getFirstInBackGround从分析中检索数据
我试图从名为Location的Parse类中检索数据,其中有两列Android 无法通过getFirstInBackGround从分析中检索数据,android,parse-platform,Android,Parse Platform,我试图从名为Location的Parse类中检索数据,其中有两列latitude和longitude。还有一个名为Username的列,其中存储了用户的objectId。 我正在将这个用户名与程序中的用户名进行匹配,但是getFirstInBackground中使用的“done”方法似乎没有执行 代码如下: for (int i = 0; i < recipient_id.size(); i++) { ParseQuery<ParseObject> query = P
latitude
和longitude
。还有一个名为Username
的列,其中存储了用户的objectId
。
我正在将这个用户名与程序中的用户名进行匹配,但是getFirstInBackground
中使用的“done”方法似乎没有执行
代码如下:
for (int i = 0; i < recipient_id.size(); i++) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.whereEqualTo("Username", recipient_id.get(i).toString());
query.getFirstInBackground(new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
if(object==null) {
//Toast.makeText(getApplicationContext(), locations.toString(), Toast.LENGTH_LONG).show();
}
else{
//Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
//e.printStackTrace();
lat = (double) object.get("latitude");
longi = (double) object.get("longitude");
Log.e("Latitude", lat+"");
locations.add(lat);
locations.add(longi);
Log.e("Locations", locations+"");
}
}
});
}
Log.e("Locations", locations+"");
for(int i=0;i
当我检查日志时,位置显示为空。字符串recipient\u id
的ArrayList
以随机顺序包含用户的objectId
s
我尝试将纬度
和经度
数据输入到用户类中,但问题仍然是一样的
编辑:我使用getInBackground
来查询ParseUser
而不是getFirstInBackground
尝试这样做。
首先,您可以将用户存储在解析查询数组列表中,如
// Other Wise Try on this way
for (int i = 0; i < recipient_id.size(); i++) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.whereEqualTo("Username", recipient_id.get(i).toString());
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
// Success
lat = (double) object.get("latitude");
longi = (double) object.get("longitude");
Log.e("Latitude", lat + "");
locations.add(lat);
locations.add(longi);
Log.e("Locations", locations + "");
} else {
// Fail
// in case its fail that a time check error like
Log.e("get Error", " Message " + e.getMessage());
}
}
});
//其他明智的做法是这样做
对于(int i=0;i
尝试其他方式,如
List<ParseQuery<ParseObject>> addQuery = new ArrayList<ParseQuery<ParseObject>>();
// first store in parse query array
for (int i = 0; i < recipient_id.length; i++) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.whereEqualTo("Username", recipient_id.get(i).toString());
addQuery.add(query);
}
ParseQuery<ParseObject> fetch = ParseQuery.or(addQuery);
fetch.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
// Success
} else {
// Fail
// in case its fail that a time check error like
Log.e("get Error", " Message " + e.getMessage());
}
}
});
List addQuery=new ArrayList();
//解析查询数组中的第一个存储
for(int i=0;i
试着这样做。
首先,您可以将用户存储在解析查询数组列表中,如
// Other Wise Try on this way
for (int i = 0; i < recipient_id.size(); i++) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.whereEqualTo("Username", recipient_id.get(i).toString());
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
// Success
lat = (double) object.get("latitude");
longi = (double) object.get("longitude");
Log.e("Latitude", lat + "");
locations.add(lat);
locations.add(longi);
Log.e("Locations", locations + "");
} else {
// Fail
// in case its fail that a time check error like
Log.e("get Error", " Message " + e.getMessage());
}
}
});
//其他明智的做法是这样做
对于(int i=0;i
尝试其他方式,如
List<ParseQuery<ParseObject>> addQuery = new ArrayList<ParseQuery<ParseObject>>();
// first store in parse query array
for (int i = 0; i < recipient_id.length; i++) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.whereEqualTo("Username", recipient_id.get(i).toString());
addQuery.add(query);
}
ParseQuery<ParseObject> fetch = ParseQuery.or(addQuery);
fetch.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
// Success
} else {
// Fail
// in case its fail that a time check error like
Log.e("get Error", " Message " + e.getMessage());
}
}
});
List addQuery=new ArrayList();
//解析查询数组中的第一个存储
for(int i=0;i