我们需要在Android中使用or
运算符和Quickblox自定义对象模块,但不会返回任何记录。
以下是迄今为止所尝试的内容:
myArray
是包含要比较的参数的String[]
数组
试用1:
QBCustomObjectRequestBuilder requestBuilder = new QBCustomObjectRequestBuilder();
requestBuilder.setPagesLimit(100);
requestBuilder.or("tag_number", myArray );
QBCustomObjects.getObjects("CollectionNum", requestBuilder, new QBCallbackImpl()
{
@Override
public void onComplete(Result result) {
if (result.isSuccess()) {
QBCustomObjectLimitedResult coresult = (QBCustomObjectLimitedResult) result;
ArrayList<QBCustomObject> co = coresult.getCustomObjects();
Log.d("Records: ", co.toString());
} else {
Log.e("Errors",result.getErrors().toString());
}
}
});
- &GT;这是触发onComplete函数,但返回NO结果
- &GT;在日食中发出警告:
类型String[]
的参数应显式转换为Object[]
,以便从类型varargs
调用QBCustomObjectRequestBuilder
方法或(String,Object ...)。也可以将其转换为Object以进行varargs
调用
Trial2:
QBCustomObjectRequestBuilder requestBuilder = new QBCustomObjectRequestBuilder();
requestBuilder.setPagesLimit(100);
requestBuilder.or("tag_number", toObjectArray(myArray) );
QBCustomObjects.getObjects("CollectionNum", requestBuilder, new QBCallbackImpl()
{
@Override
public void onComplete(Result result) {
if (result.isSuccess()) {
QBCustomObjectLimitedResult coresult = (QBCustomObjectLimitedResult) result;
ArrayList<QBCustomObject> co = coresult.getCustomObjects();
Log.d("Records: ", co.toString());
} else {
Log.e("Errors",result.getErrors().toString());
}
}
});
public static Object[] toObjectArray(Object array)
{
int length = Array.getLength(array);
Object[] ret = new Object[length];
for(int i = 0; i < length; i++)
ret[i] = array[i];
return ret;
}
- &GT;这不是触发onComplete
- &GT;这不是返回结果。
请注意,区别在于是发送myArray
还是toObjectArray(myArray)
。
请指教,Android中的自定义对象中是否有使用或运算符的工作示例?