「已注销」 2016-02-27 16:18 采纳率: 0%
浏览 1458
已采纳

空指针,大神版主帮帮忙吧

public class StartLoginActivity extends Activity {

// 账号输入框
private EditText inputAccount;

//密码输入框
private EditText inputPassword;

// 登录按钮
private Button loginButton;

private GlobalVariable mGlobalVariable;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);

    //透明状态栏
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    //透明导航栏
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

    inputAccount = (EditText) findViewById(R.id.account_edittext);
    inputPassword = (EditText) findViewById(R.id.password_edittext);

    Button loginButton = (Button) findViewById(R.id.login_button);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View source) {
            GlobalVariable mGlobalVariable = new GlobalVariable();
            new GeocodeingTask().execute( mGlobalVariable.account = inputAccount.getText().toString(), mGlobalVariable.password = inputPassword.getText().toString());
        }
    });
}

public class GeocodeingTask extends AsyncTask<String, Void, List<GlobalVariable>> {

    @Override
    protected List<GlobalVariable> doInBackground(String... params) {

        String json = RequestUtil.RequestJson("http://wechat.svner.com/login.php", "POST", params[0]);
        Gson gson = new Gson();
        class tmp {
            public int result;
        }
        System.out.println(json);
        tmp n = gson.fromJson(json, tmp.class);
        if (n.result == 0) {
            Toast.makeText(getApplicationContext(), "账号或密码错误", Toast.LENGTH_SHORT).show();
            System.out.print("error============================");
        } else {
            Intent intent = new Intent(StartLoginActivity.this, StartMainBodyActivity.class);
            startActivity(intent);
        }
        return null;
    }
}

}
。。。
。。。
。。。
public class GlobalVariable {
public String account;
public String password;
}
图片说明图片说明

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-02-27 22:22
    关注

    tmp n = gson.fromJson(json, tmp.class);
    看下这一步解析json是不是正确,服务器怎么返回的。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?