Android: Retrieving Password via registered Email on My Server

Posted by Raghavan'G' on Stack Overflow See other posts from Stack Overflow or by Raghavan'G'
Published on 2011-06-29T06:57:59Z Indexed on 2011/06/29 8:22 UTC
Read the original article Hit count: 174

i am working on retrieving password to the user when he submits his mail id that he registered on my server. I need to check whether he entered correct registered id and give him response by sending password to his corresponding mail and set dialog as password sent to your mail or if he entered wrong mail id i have to show mail id not registered... Any Idea? This is my code...

             package com.soap;
             import java.util.regex.Matcher;
             import java.util.regex.Pattern;
             import org.ksoap2.SoapEnvelope;
             import org.ksoap2.serialization.PropertyInfo;
             import org.ksoap2.serialization.SoapObject;
             import org.ksoap2.serialization.SoapSerializationEnvelope;
             import org.ksoap2.transport.HttpTransportSE;
             import android.app.Activity;
             import android.app.Dialog;
             import android.app.ProgressDialog;
            import android.os.Bundle;
          import android.util.Log;
            import android.view.View;
           import android.view.View.OnClickListener;
           import android.widget.Button;
          import android.widget.EditText 

       public class Register extends Activity {
/** Called when the activity is first created. */

// static Spinner operator = null;
private static final String SOAP_ACTION = "......";
private static final String METHOD_NAME = "......";
private static final String NAMESPACE = "......";
private static final String URL = "My site";
private static final String TAG = "HELLO";

Thread t;
ProgressDialog dialog;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.forgotpasswordpage);
    Button signin = (Button) findViewById(R.id.fpwdsubmit);

    signin.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog(0);
            t = new Thread() {
                public void run() {
                    register();
                }
            };
            t.start();
        }
    });
}

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case 0: {
        dialog = new ProgressDialog(this);
        dialog.setMessage("Please wait while connecting...");
        dialog.setIndeterminate(true);
        dialog.setCancelable(true);
        return dialog;
    }
    }
    return null;
}

public void register() {
    Log.v(TAG, "Trying to Login");
    EditText etxt_user = (EditText)findViewById(R.id.fpedtext);
    String email_id = etxt_user.getText().toString();
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("Email", email_id);
     Pattern EMAIL_ADDRESS_PATTERN =Pattern.compile(
             "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
             "\\@" +
             "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
             "(" +
             "\\." +
             "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
             ")+");
     Matcher matcher = EMAIL_ADDRESS_PATTERN.matcher(email_id);
     if(matcher.matches()){
      Log.v(TAG, "Your email id is valid ="+email_id);
    //  System.out.println("Your email id is valid ="+email);
     }
     else{
   //  System.out.println("enter valid email id");
      Log.v(TAG, "enter valid email id" );
     }
    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.dotNet = true;
    soapEnvelope.setOutputSoapObject(request);
    HttpTransportSE aht = new HttpTransportSE(URL);
    try {
        aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
        aht.call(SOAP_ACTION, soapEnvelope);
    SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
        Log.v("TAG", String.valueOf(resultsRequestSOAP));
    } catch (Exception e) {

        e.printStackTrace();
    }

}

}

© Stack Overflow or respective owner

Related posts about android

Related posts about web-services