蛋包饭 2016-05-13 16:47 采纳率: 0%
浏览 2180

用java开发一个安卓客户端在线交流APP,是怎么实现添加好友的?求大神帮我看看这段代码。

图片说明private void submit() {
dialog = ProgressDialog.show(this, "提示", "处理中..");
new AsyncTask() {

        @Override
        protected String doInBackground(String... params) {
            String urlString = AppConstant.getUrl(getApplicationContext())
                    + "ServletService";
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("Action", "addfriend");
            map.put("userid1", user.getId());
            map.put("userid2", list.get(row).getId());
            String result = httpHelper.HttpPost(urlString, map);
            return result;
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            dialog.dismiss();
            if (!TextUtils.isEmpty(result)) {
                if (result.trim().equals("1")) {
                    toastUtil.show("添加成功,等待对方验证");
                } else if (result.trim().equals("-1")) {
                    toastUtil.show("你已经添加对方为好友,等待对方审核");
                } else if (result.trim().equals("-2")) {
                    toastUtil.show("对方拒绝你的请求");
                } else if (result.trim().equals("-3")) {
                    toastUtil.show("你们已经是好友");
                }
            } else {
                toastUtil.show("操作失败");
            }
            finish();
        }
    }.execute();
}

//因为安卓模拟器上运行的时候出bug,一点添加好友,就会提示程序已停止运行,然后自动退出,求大神指出哪里出了问题

  • 写回答

3条回答 默认 最新

  • devmiao 2016-05-13 21:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果