“资源被收购但从未发布”与parse.com的错误

时间:2016-01-25 12:41:21

标签: java android parse-platform

在附加的堆栈跟踪中获取资源但从未发布。有关避免资源泄漏的信息,请参阅java.io.Closeable。 我正在尝试登录并使用我的应用程序注册,并发现上述错误。 以下是我的主要活动代码。

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser())) {
        Intent intent = new Intent(MainActivity.this, LoginSignupActivity.class);
        startActivity(intent);
        finish();
    } else {
        ParseUser currentUser = ParseUser.getCurrentUser();
        if (currentUser != null) {
            Intent intent = new Intent(MainActivity.this, Welcome.class);
            startActivity(intent);
            finish();
        } else {
            Intent intent = new Intent(MainActivity.this, LoginSignupActivity.class);
            startActivity(intent);
            finish();
        }
    }

}
}

以下是我的LoginSigupActivity代码

public class LoginSignupActivity extends ActionBarActivity {

Button loginButton;
Button signupButton;
@Override
protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_login_signup);
loginButton = (Button) findViewById(R.id.btn_launcherSignIn);
    signupButton = (Button) findViewById(R.id.btn_launcherSignUp);

    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
    Intent intent = new Intent(LoginSignupActivity.this, LoginActivity.class);
                        startActivity(intent);
                        finish();
    }
    });
    signupButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
    Intent intent = new Intent(LoginSignupActivity.this, SignUpActivity.class);
            startActivity(intent);
            finish();
        }
    });

}
}

Folloing是我的登录活动类代码

public class LoginActivity extends ActionBarActivity {
Button loginButton;

String txtUsername;
String txtPassword;
EditText password;
EditText username;

@Override
protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_login);

    loginButton = (Button) findViewById(R.id.login);

    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            txtUsername = username.getText().toString();
            txtPassword = password.getText().toString();

            ParseUser.logInInBackground(txtUsername, txtPassword, new LogInCallback() {
                @Override
                public void done(ParseUser user, ParseException e) {
                    if (user != null) {
                        Intent intent = new Intent(LoginActivity.this, Welcome.class);
                        startActivity(intent);
                        finish();
                    } else {
                        Toast.makeText(getApplicationContext(), "This user does not exist! Please Sign up", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }
    });
}
}

以下是我的注册活动代码

public class SignUpActivity extends ActionBarActivity {
Button signupButton;

String txtUsername;
String txtPassword;
EditText password;
EditText username;

@Override
protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_signup);

    signupButton = (Button) findViewById(R.id.signup);

    signupButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            txtUsername = username.getText().toString();
            txtPassword = password.getText().toString();
            if(txtUsername.equals("") && txtPassword.equals("")){
                Toast.makeText(getApplicationContext(), "Please complete the signup form", Toast.LENGTH_SHORT).show();
            }else{
                ParseUser user = new ParseUser();
                user.setUsername(txtUsername);
                user.setPassword(txtPassword);
                user.signUpInBackground(new SignUpCallback() {
                    @Override
                    public void done(ParseException e) {
                        if(e==null){
                            Toast.makeText(getApplicationContext(), "Signed up successfully...!", Toast.LENGTH_SHORT).show();
                        }else{
                            Toast.makeText(getApplicationContext(), "Signup Error", Toast.LENGTH_SHORT).show();
                        }
                    }
                });
            }
        }
    });
}
}

以下是我的Parse连接器类代码

public class ParseConnecter extends MultiDexApplication{

@Override
public void onCreate() {
    super.onCreate();

    Parse.initialize(this, "zblr0TmjldGaV2xSl5******aFhe6DW78FjA2u", "9Ys6j7uY68115********2pvo5Ldfia");
    ParseInstallation.getCurrentInstallation().saveInBackground();
    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);


}


}

0 个答案:

没有答案