【发布时间】:2016-10-28 18:49:11
【问题描述】:
我最近一直在设置移动应用程序以使用我的流星服务器。作为其中的一部分,我必须从 android 传递流星网络应用程序数据。不幸的是,我收到一个错误,告诉我我传递的 java 对象“将被序列化为null”。如何防止这种情况发生?
JSONObject json = new JSONObject();
try{
json.put("Foo", "1");
json.put("Blah", 0);
}catch (JSONException e){
}
Object[] object = new Object[1];
object[0] = json;
System.out.println(object + ", " + object[0] + ", " + object[0].toString());
mMeteor.call("xxx", object, new ResultListener() {
@Override
public void onSuccess(String result) {
}
@Override
public void onError(String error, String reason, String details) {
}
});
}
@Override
public void onError(String error, String reason, String details) {
}
});
Android/Meteor 接口库函数
public void callWithSeed(final String methodName, final String randomSeed, final Object[] params, final ResultListener listener) {
// create a new unique ID for this request
final String callId = uniqueID();
// save a reference to the listener to be executed later
if (listener != null) {
mListeners.put(callId, listener);
}
// send the request
final Map<String, Object> data = new HashMap<String, Object>();
data.put(Protocol.Field.MESSAGE, Protocol.Message.METHOD);
data.put(Protocol.Field.METHOD, methodName);
data.put(Protocol.Field.ID, callId);
if (params != null) {
data.put(Protocol.Field.PARAMS, params);
}
if (randomSeed != null) {
data.put(Protocol.Field.RANDOM_SEED, randomSeed);
}
send(data);
}
【问题讨论】:
-
你有解决办法吗?