vendredi 3 avril 2015

Android App Dev: Forgot Password using Parse.com


Vote count:

0




I recently use Parse.com for my android app project. I successfully created login and signup actiivity, But facing problem with forgot password activity.


here is mine activity of forgot password.



<pre>import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import com.parse.ParseException;


public class ForgotPassword extends ActionBarActivity {

protected EditText mEmail;
protected Button mResetPassword;

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

mEmail =(EditText)findViewById(R.id.Emailid);
mResetPassword = (Button)findViewById(R.id.reset_password_button);
mResetPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = mEmail.getText().toString();
email = email.trim();

if(email.isEmpty()){
AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPassword.this);
builder.setMessage(R.string.email_error_message)
.setTitle(R.string.email_error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
else{
ParseUser.requestPasswordResetInBackground(email,
new RequestPasswordResetCallback() {
public void done(ParseException e) {
if (e == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPassword.this);
builder.setMessage(R.string.email_success_message)
.setTitle(R.string.email_success_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPassword.this);
builder.setMessage(e.getMessage())
.setTitle(R.string.email_error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
}
}
});
}
}


I already try with blank email ID, and get error message, because I check with this code "if(email.isEmpty()" so simply my code is working fine in background, but when I enter real Email Id that is already stored in Parse database, then I get this error message " no user found with email contact@goyllo.com" . I don't why I get this message, but I already have one account with this email Id contact@goyllo.com. Correct me guys.



asked 27 secs ago







Android App Dev: Forgot Password using Parse.com

Aucun commentaire:

Enregistrer un commentaire