2

i have to activities AnswerQuestion.java and SendAnswerToServer.java, and i want to send data from first activity to another one

on the AnswerQuestion activity i write this:

Bundle basket = new Bundle();
basket.putString("time", timeToAnswer+"");
Intent goToSendServer = new Intent(AnswerQuestion.this, SendAnswerToServer.class);
goToSendServer.putExtras(basket);
startActivity(goToSendServer);

my question what have i to write on the SendAnswerToServer activity , thank you

user1476841
  • 79
  • 1
  • 10
  • possible duplicate of [How to get data from other activity in android?](http://stackoverflow.com/questions/4792829/how-to-get-data-from-other-activity-in-android) – Sam Jun 24 '12 at 18:12
  • @Sam i saw it, yes duplicate, thank you – user1476841 Jun 24 '12 at 18:15
  • My comment was automatically created when I made a note visible to other +2k reputation users. It is harmless, please take no offense. If enough other users agree with me then your question will be marked and you'll get advice on how to distinguish it if you want. – Sam Jun 24 '12 at 19:29

1 Answers1

11

in SendAnswerToServer Activity:

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    Bundle bundle = this.getIntent().getExtras();  

    if(bundle !=null)
    {
            //ObtainBundleData in the object 
      String strdata = bundle.getString("time"); 
       //Do something here if data  received
     }
     else
     {
       //Do something here if data not received
     }
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213