2012-12-12 50 views
-1

我试图开发一个Android应用程序。在这里我必须开发忘记密码option.i必须单击忘记密码textview意味着它是去下一个activity.next活动有输入用户名。我必须从mysql数据库检查用户名是有效还是无效。用户名有效意味着它是下一个活动。下一个活动有输入一些文本(密码)字段。我必须点击更新按钮意味着该用户的密码被更新。将数据从一个活动传递到Android应用程序中的下一个活动

在这里,我已经完成了用户名是有效的和无效activity.but我怎么可以传递用户名数据到下一个活动和更新这些特定用户的密码。

在这里,我必须更新密码(第二次活动)从用户名(基于第一次活动)。如何开发these.please帮助我。

这是我的第一个活动:

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); 
      } 

下一个活动代码是象下面这样:

 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); 

如何从1日的活动传递的用户名值下一个活动。

回答

0

假设你从一个Activity到另一个传递一个string值,在第一活动:在OnCreate()

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); 

在第二Activity,得到string值如下:

Intent idValues = getIntent(); 
String seq = idValues.getStringExtra("lID"); 
+0

在firstactivity我有传递数据。所以我已经使用下面的代码:intent.putExtra(“用户名”,登录);这是正确的only.now我怎么能得到第二活动的数据 – user1897014

+0

看到我编辑的答案... –

+0

嗨,这是完整的我的源代码:第一活动:http://pastie.org/5514961第二活动代码:http: //pastie.org/5514963请检查我的代码,并给我solution.i已更新我的代码从您的上述solution.i没有更新我的密码 – user1897014

0

-使用IntentputExtra()getExtras()方法一起。

例如:

活动A:

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

活性B:

String userName = getIntent().getExtras().getString("username"); 
+0

现在我的密码也没有更新mysql数据库。现在我没有得到任何回应 – user1897014

相关问题