Android Parse"无效的会话令牌"错误

时间:2015-07-16 22:57:36

标签: android parse-platform

我是Android的新手,我被困在一个似乎是一个简单的修复问题但我不知道我做错了什么!我需要做的只是注册一个用户,由于某种原因,e永远不会等于null,因此它会直接进入else部分,这会给我无效的会话令牌消息。这是注册部分的代码,我看了几千次!:

protected EditText mUsername;
protected EditText mPassword;
protected EditText mEmail;
protected Button mSignUpButton;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up_manager);

    mUsername = (EditText)findViewById(R.id.usernameField);
    mPassword = (EditText)findViewById(R.id.passwordField);
    mEmail = (EditText)findViewById(R.id.emailField);
    mSignUpButton = (Button)findViewById(R.id.signupButton);

    mSignUpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = mUsername.getText().toString();
            String password = mPassword.getText().toString();
            String email = mEmail.getText().toString();

            //trims the spaces
            username = username.trim();
            password = password.trim();
            email = email.trim();

            //if one of the text edits is empty send them a message with a                                    title with an ok button.
            if(username.isEmpty() || password.isEmpty() || email.isEmpty()){
                AlertDialog.Builder builder = new AlertDialog.Builder(SignUpManagerActivity.this);
                builder.setMessage(R.string.signup_error_message)
                        .setTitle(R.string.signup_error_title)
                        .setPositiveButton(android.R.string.ok, null);

                AlertDialog dialog = builder.create();
                dialog.show();
            }
            else {
                setProgressBarIndeterminateVisibility(true);//the progress circle is active.

                //creating a new parse user.
                ParseUser pUser = new ParseUser();
                pUser.setUsername(username);
                pUser.setPassword(password);
                pUser.setEmail(email);

                pUser.signUpInBackground(new SignUpCallback() {
                    @Override
                    public void done(ParseException e) {
                        setProgressBarIndeterminateVisibility(false);//the progress circle is not active.
                        if (e == null) {
                            Intent intent = new Intent(SignUpManagerActivity.this, LoginManagerActivity.class);
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                            startActivity(intent);
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(SignUpManagerActivity.this);
                            builder.setMessage(e.getMessage())
                                    .setTitle(R.string.signup_error_title)
                                    .setPositiveButton(android.R.string.ok, null);

                            AlertDialog dialog = builder.create();
                            dialog.show();
                        }
                    }
                });

            }
        }
    });



}

请提前帮助,谢谢!

2 个答案:

答案 0 :(得分:8)

首先在这里发布,但我有同样的错误。如果我错了,请纠正我,但我相信我的问题是我可以创建一次用户然后获得无效的会话令牌。我认为这是因为"会议"即使您可以关闭并重新运行应用程序,Parse网站上的终端仍然会登录。

通过在尝试创建新的解析用户之前添加以下代码,我解决了我的问题。

ParseUser currentUser = ParseUser.getCurrentUser();
currentUser.logOut();

希望有所帮助。干杯!

答案 1 :(得分:1)

1.这是因为删除了会话而没有注销,所以你要做的就是

输入以下代码

load csv with headers from 
"file:C:/wamp/www/fantapappa/nodes.csv"
as nodes
create (n {id: nodes.Node, name: nodes.Name, type: nodes.Label})
return n

load csv with headers from 
"file:C:/wamp/www/fantapappa/rels.csv" 
as rels 
match (from {id:rels.From}), (to {id: rels.To})
create from-[:REL {type: rels.'Relationship'}]->to
return from, to

match (m {type:"Male"}), (f {type:"Female"})
set m:Male, f:Female
return m,f

2.如果第一次无效,请转到设置您的模拟器,然后转到App选择您的应用,然后点击清除数据,但要小心这将清除您的数据库