Вопрос

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

Это было полезно?

Решение

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
     }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top