Android 在vk中过帐状态出错

Android 在vk中过帐状态出错,android,vk,Android,Vk,我正在尝试将vk集成到android应用程序中。为此,我尝试在这个链接中遵循以下说明 我已使用此代码成功登录vk。但是在尝试在我的墙上发布状态后,我得到了以下错误 02-20 14:08:54.779: W/System.err(2945): java.lang.NullPointerException 02-20 14:08:54.789: W/System.err(2945): at com.perm.kate.api.Api.createWallPost(Api.java:1200

我正在尝试将vk集成到android应用程序中。为此,我尝试在这个链接中遵循以下说明

我已使用此代码成功登录vk。但是在尝试在我的墙上发布状态后,我得到了以下错误

02-20 14:08:54.779: W/System.err(2945): java.lang.NullPointerException
02-20 14:08:54.789: W/System.err(2945):     at com.perm.kate.api.Api.createWallPost(Api.java:1200)
02-20 14:08:54.789: W/System.err(2945):     at com.perm.kate.api.sample.MainActivity$5.run(MainActivity.java:100)
在MainActivity.java的第100行中定义了以下代码

api.createWallPost(account.user_id, text, null, null, false, false, false, null, null, null, null, null, null);
public WallMessage repostWallPost(String object, String message, Long gid, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
        Params params = new Params("wall.repost");
        params.put("group_id", gid);
        params.put("message", message);
        params.put("object", object);
        addCaptchaParams(captcha_key, captcha_sid, params);
        JSONObject root = sendRequest(params);
        JSONObject response = root.getJSONObject("response");
        WallMessage wall=new WallMessage(); 
        wall.id = response.optLong("post_id");
        wall.like_count=response.optInt("likes_count");
        wall.reposts_count=response.optInt("reposts_count");
        return wall;
    }
在API.java的第1200行中定义了以下代码

api.createWallPost(account.user_id, text, null, null, false, false, false, null, null, null, null, null, null);
public WallMessage repostWallPost(String object, String message, Long gid, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
        Params params = new Params("wall.repost");
        params.put("group_id", gid);
        params.put("message", message);
        params.put("object", object);
        addCaptchaParams(captcha_key, captcha_sid, params);
        JSONObject root = sendRequest(params);
        JSONObject response = root.getJSONObject("response");
        WallMessage wall=new WallMessage(); 
        wall.id = response.optLong("post_id");
        wall.like_count=response.optInt("likes_count");
        wall.reposts_count=response.optInt("reposts_count");
        return wall;
    }
createwallpost的方法定义如下:

public long createWallPost(long owner_id, String text, Collection<String> attachments, String export, boolean only_friends, boolean from_group, boolean signed, String lat, String lon, Long publish_date, Long post_id, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
        Params params = new Params("wall.post");
        params.put("owner_id", owner_id);
        params.put("attachments", arrayToString(attachments));
        params.put("lat", lat);
        params.put("long", lon);
        params.put("message", text);
        if(export!=null && export.length()!=0)
            params.put("services",export);
        if (from_group)
            params.put("from_group","1");
        if (only_friends)
            params.put("friends_only","1");
        if (signed)
            params.put("signed","1");
        params.put("publish_date", publish_date);
        if (post_id > 0)
            params.put("post_id", post_id);
        addCaptchaParams(captcha_key, captcha_sid, params);
        JSONObject root = sendRequest(params, true);
        JSONObject response = root.getJSONObject("response");
        long res_post_id = response.optLong("post_id");
        return res_post_id;
    }
public long createWallPost(long owner\u id、字符串文本、集合附件、字符串导出、仅布尔型朋友、来自组的布尔型、布尔型签名、字符串lat、字符串lon、长发布日期、long post\u id、字符串验证码密钥、字符串验证码sid)引发IOException、JSONException、KEException{
Params Params=新参数(“墙柱”);
参数put(“所有者id”,所有者id);
参数put(“附件”,arrayToString(附件));
参数put(“lat”,lat);
参数put(“long”,lon);
参数put(“消息”,文本);
if(export!=null&&export.length()!=0)
参数put(“服务”,出口);
如果(来自_集团)
参数put(“来自集团”,“1”);
如果(只有朋友)
参数put(“仅限朋友”、“1”);
如有(签名)
参数卖出价(“已签署”、“1”);
参数put(“发布日期”,发布日期);
如果(post_id>0)
参数put(“post_id”,post_id);
添加验证码参数(验证码密钥、验证码sid、参数);
JSONObject root=sendRequest(参数,true);
JSONObject response=root.getJSONObject(“response”);
long res_post_id=response.optLong(“post_id”);
返回res_post_id;
}
原因是什么?你能帮我消除这个错误吗?

这帮了我:

api.createWallPost(account.user_id,message,null,null,false,false,false,null,null,new Long(0),new Long(0),null,null)


我希望它将对您有所帮助

您可以直接使用VK Android Sdk。我用

要在墙上张贴,您需要一些授权:

VKSdk.login(ActivityLogin.this,VKScope.FRIENDS,VKScope.WALL,VKScope.PHOTOS);

发布一些代码please@osimer请张贴
createWallPost()
。您收到一个错误,但帖子是否确实出现在vkontakte墙上?我已经发布了CreateWallPost()的代码。请检查否该帖子未发布在mt wall中。@Osimerpot您应该找到发生
NullPointerException
的确切位置。它位于
createWallPost