我没有得到RSS feed值。我认为获取Feed值时出错

时间:2012-02-08 06:21:33

标签: android json

我是JSON的新手。请任何人提供获取JSON值的示例代码...... 当我点击登录按钮,我想从Json对象获取用户令牌值。请帮助我..

这是我的代码..

先谢谢你。

            public void onClick(View v) {
            switch(v.getId()){

            case R.id.btnLogin:
                 txtUserName=(EditText)this.findViewById(R.id.txtUname);
                txtPassword=(EditText)this.findViewById(R.id.txtPwd);

        String uname = txtUserName.getText().toString();
        String pass = txtPassword.getText().toString();

        if(uname.equals("") || uname == null){
            Toast.makeText(getApplicationContext(), "Username Empty", Toast.LENGTH_SHORT).show();
        }else if(pass.equals("") || pass == null){
            Toast.makeText(getApplicationContext(), "Password Empty", Toast.LENGTH_SHORT).show();
        }else{
            boolean validLogin = validateLogin(uname, pass, Loginpage.this);
            if(validLogin){

            }
        }
        break;

    case R.id.btnCancel:
        Intent i = new Intent(Loginpage.this,Loginpage.class);
        startActivity(i);
        //finish();
        break;

    }
}




private boolean validateLogin(String uname, String pass, Loginpage loginpage) {
     System.out.println("UserToken...");
        loginuser();

    Intent intent = new Intent(Loginpage.this, Main.class);

    intent.putExtra("tokenNumber", token);

    startActivity(intent);


    return true;


}

private void loginuser() {
    // TODO Auto-generated method stub


        JSONObject json = JSONfunctions.getJSONfromURL("http://xxx.xxx.x.xxx/my url link...");

        token = null;
                try {
                        token = json.getString("UserToken");
                } catch (JSONException e) {                
                        e.printStackTrace();
                }    
            System.out.println("UserToken:"+token);

}

1 个答案:

答案 0 :(得分:0)

您必须搜索网络才能获得Example.Bye方式以下是链接。3 minute to json 您还必须访问此网站以使一切清晰Json