Wednesday, April 11, 2012

Passing value back from a called activity

I am new to android programming and have the following question.



I have an Activity (screen) which calls another activity (screen). I can pass values back from Activity2 by creating an intext and using putExtras. Then when I return to my main activity1 then I can (onActivityResult) I can retrive the string value pairs from the intent that is returned.



Question 1 if Activity2 is finished what is the possibility that the Intent i created in there can get freed up if the garbage collector kicks in? Or does android not clear up any memory like that until the app is exited.



Question 2 ) If I then go back into Activity2 and again do a "new Intent ....." is that allocating even more memory and if so is it inefficient?"



Question 3 - Is there a better way of passing data back from a called activity to the calling activity or is using an Intent and putExtras etc the only way?



Thanks
Tony





1 comment:

  1. My Suggestion Would be.

    If you have data which has been used various activity then Instead passing the data by using the Intent from 1 activity to another. create Global Level Static variable and then access that that Global variable through out the application.

    link|improve this answer

    ReplyDelete