I have 3 activities : activity "valider" as 1st activity and the second is activivty "connexion" and finally the inscription activity , i hope to pass from 1st==> second==> third and viceversa from third==> second==>first activity. Please someone can help me?
            Asked
            
        
        
            Active
            
        
            Viewed 929 times
        
    -1
            
            
        - 
                    What is your question actuallly? Please explain in detail. – R.R.M May 09 '17 at 09:35
- 
                    1Use `Intent` to open from 1 to 2 to 3 , `startActivityForResult` for the viceversa – Tony May 09 '17 at 09:36
- 
                    Possible duplicate of [How do I pass data between Activities in Android application?](http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application) – Pro Mode May 09 '17 at 09:38
- 
                    1I'm using startActivityForResult but not change – ferjaoui wissal May 09 '17 at 09:45
- 
                    1@ferjaouiwissal you should post your code then – Tony May 09 '17 at 09:45
- 
                    thank u for your help , i found the error – ferjaoui wissal May 09 '17 at 09:54
- 
                    2Possible duplicate of [How can I pass values between Activities on Android?](http://stackoverflow.com/questions/5852677/how-can-i-pass-values-between-activities-on-android) – Sufian May 09 '17 at 15:27
2 Answers
0
            
            
        There are multiple ways to share data with different activities your question is repeated please check this: What's the best way to share data between activities?
0
            
            
        To pass data in the First:
void send() {
Intent intent = new Intent(this, Second.class);
intent.putExtra("NAME",some_value);//your data
startActivityForResult(intent, yourSomeId);// if you want to retrieve callback data later
startActivity(intent);//or simply
}
in the Second
in
@Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    if(extras == null) {
        yourData = null;
    } else {
        yourData = extras.getString("NAME");
    }
}
to send data back:
charge data in the second activity:
void back() {
    Intent intent = new Intent();
    intent.putExtra("NAME", yourdata);
    setResult(RESULT_OK, intent);
    finish();
}
and retrieve in the First:
 @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data == null) {return;}
    yourdata = data.getStringExtra("NAME");
  }
you can send the data to the third activity in the same way.
 
    
    
        Vyacheslav
        
- 26,359
- 19
- 112
- 194
 
     
    