-1

i have try to develop one android app.here i have to develop forget password option.i have to click forget password textview means it is go to next activity.next activity have to enter the username of that registered user.i have to check the username is valid or invalid from mysql database.the username is valid means it is goto next activity .next activity have enter some text(password) field.here i have to click update button means the password is updated for that user.

Here i have done the username is valid and invalid activity.but how can i pass username data to next activity and update password for these particular user.

Here i have to update password(2nd activity) from username (based on 1st activity).How can i develop these.please help me.

This is my 1st activity:

 PropertyInfo unameProp =new PropertyInfo();
    unameProp.setName("Username");//Define the variable name in the web service method
    unameProp.setValue(login);//set value for userName variable
    unameProp.setType(String.class);//Define the type of the variable
    request.addProperty(unameProp);
     ----
   -----
   if(status.equals("Valid Username"))
           {

               Intent intent = new Intent(Login.this,RetailerActivity.class);
               intent.putExtra("Username", login);
               startActivity(intent);
           }

The next activity code is like below:

        btninsert = (Button)findViewById(R.id.btn_insert1);
    btninsert.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
             Intent in = getIntent();
       EditText userPassword = (EditText) findViewById(R.id.edittext);
             String user_Name = userPassword.getText().toString();
             SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            PropertyInfo unameProp =new PropertyInfo();
            unameProp.setName("userPassword");//Define the variable name in the web service method
            unameProp.setValue(user_Name);//Define value for fname variable
            unameProp.setType(String.class);//Define the type of the variable
            request.addProperty(unameProp);
            PropertyInfo idProp =new PropertyInfo();
            idProp.setName("Username");//Define the variable name in the web service method
            idProp.setValue();//Define value for fname variable
            idProp.setType(String.class);//Define the type of the variable
            request.addProperty(idProp);

How can i pass username value from 1st activity to next activity.

user1897014
  • 143
  • 4
  • 14

3 Answers3

0

Assuming that you are passing a string value from one Activity to another, In first Activity:

    String lID = "Your Text here"; 
    Intent i= new Intent(<ClassName>.this, <Navigate to Class>.class)
            i.putExtra("lID", lID); // send to another activity as key-value pair
          startActivity(i);

In second Activity, get the string value in OnCreate() as below:

 Intent idValues = getIntent();
 String seq = idValues.getStringExtra("lID");
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
  • in firstactivity i have to pass the data .so i have used below code: intent.putExtra("Username", login); it is correct only.now how can i get the data on 2nd activity – user1897014 Dec 12 '12 at 08:57
  • hi this is full my source code:1st activity:http://pastie.org/5514961 2nd activity code:http://pastie.org/5514963 please check my code and give me solution.i have updated my code from your above solution.i didn't update my password – user1897014 Dec 12 '12 at 09:09
  • The code is looking fine. Now you will get Username in String "seq" of 2nd Activity right? – Avadhani Y Dec 12 '12 at 09:13
  • yes correct.how can i do.i have to update password for that entered user – user1897014 Dec 12 '12 at 09:15
  • i have to enter login(username).after i have to click submit button.now i have to enter some text(password) after that have to click update button means these password is update in my mysql database. – user1897014 Dec 12 '12 at 09:19
0

you should search before you add a new question:

Look here: How do I get extra data from intent on Android?

Community
  • 1
  • 1
fgeorgiew
  • 1,194
  • 2
  • 8
  • 25
0

- Use Intent along with putExtra() and getExtras() methods.

Eg:

Activity A:

Intent i = new Intent(Activity_A.this, Activity_B.class);
i.putExtra("username",login);
startActivity(i);

Activity B:

String userName = getIntent().getExtras().getString("username");
Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75