2012-12-12 49 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

相關問題