Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android passing objects between activities

Tags:

android

Say if I have a locationManager(LM) object in activity A, which is my main menu. All the sub-activities need to use LM. In a good design, should I pass LM object to sub-activities? How? Please suggest some good coding pattern. Thanks.

like image 282
Stan Avatar asked Feb 25 '26 12:02

Stan


1 Answers

You could use an Application object, that is what API proposes for those cases, when you have multiple Activities with common state.

like image 169
Fernando Miguélez Avatar answered Feb 27 '26 03:02

Fernando Miguélez