Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android send data from activity to activity using bundle

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

like image 909
user1476841 Avatar asked Feb 11 '26 13:02

user1476841


1 Answers

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
     }
like image 73
ρяσѕρєя K Avatar answered Feb 13 '26 07:02

ρяσѕρєя K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!