我正在为vk.com编写客户端并收到错误。
我使用碎片,我认为它是由碎片引起的。
过程:ru.dennes544.vkapp,PID:9357 java.lang.NullPointerException:尝试调用虚方法'java.util.ArrayList com.perm.kate.api.Api.getProfiles(java.util.Collection,java.util.Collection,java.lang.String,java.lang空对象引用上的.String,java.lang.String,java.lang.String)' 在ru.dennes544.vkapp.Profile $ 1.run(Profile.java:89)
几行代码:
private void loadAccInfo(){
new Thread(){
@Override
public void run(){
Collection uid = new ArrayList();
try {
uid.add(account.user_id);
profiles = api.getProfiles(uid, null, "sex", "Nom", null, null).get(0);
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} catch (KException e) {
e.printStackTrace();
}
和getProfiles声明:
public ArrayList<User> getProfiles(Collection<Long> uids, Collection<String> domains, String fields, String name_case, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
if (uids == null && domains == null)
return null;
if ((uids != null && uids.size() == 0) || (domains != null && domains.size() == 0))
return null;
Params params = new Params("users.get");
if (uids != null && uids.size() > 0)
params.put("user_ids",arrayToString(uids));
if (domains != null && domains.size() > 0)
params.put("user_ids",arrayToString(domains));
params.put("fields",fields);
params.put("name_case",name_case);
addCaptchaParams(captcha_key, captcha_sid, params);
JSONObject root = sendRequest(params);
JSONArray array=root.optJSONArray("response");
return User.parseUsers(array);
}