So, the problem is this: from one activation, switch to another, and transfer some data to the previous one. This code was the result:

public void onClick(View arg0) { // TODO Auto-generated method stub if (arg0 == button1) { int year = cal.getYear(); int month = cal.getMonth(); int day = cal.getDayOfMonth(); int hour = timer.getCurrentHour(); int minute = timer.getCurrentMinute(); boolean calenda = true; Intent z = new Intent(this, Newnote.class); z.putExtra("year", year); z.putExtra("month", month); z.putExtra("day", day); z.putExtra("hour", hour); z.putExtra("minute", minute); z.putExtra("calenda", calenda); super.finish(); } } 

But the problem is that this data is not transmitted. As I understand it, I definitely need to open the activity so that all these parameters are transmitted to it. I would be glad, but then it turns out that the application is open 2 Activity.

Question: is it possible to somehow transfer the data without opening the activation or, like when opening the second activation, close the first?

    1 answer 1

    You need to activate Activi B from activit B using the startActivityForResult () method . Then, in activity B, call the setResult () method, where to transfer the Intent object with the data.

    Then, in Activate A, override the onActivityResult () method in which you will retrieve the received data. Be careful, because if in activity A you have dialog boxes, then when they are closed, the onActivityResult () method will also work.

    At the expense of two activations: when you open the second one from the first, the onPause () method will work in the first

    • it is also possible with 2nd, through intent, then the first will have to finish all the time ... - Gorets
    • Yes, there are many ways, for example the same BroadcastReciever - Roman Zakharov
    • Yeah, or in one activit write in the database, and in the other read =) or right)) - Gorets
    • : DDD neighing - Roman Zakharov
    • @ Roman - you describe a way to return the result from the activation - this is a bit different from what the subject expects :) - Barmaley