I am not sure if this is the right way to do it. I have a ChatActivity using FrameLayout in frame.xml. This activity needs to be reused across 5 activities. Is there anyway to do a code reuse? This acitivty runs independently of other activities.
For example, in activity A, which uses main.xml, I want ChatActivity and frame.xml to be included. What is the best way to achieve this besides merging the ChatActivity and frame.xml into activity A and main.xml? Merging the activities would mean that I have to copy and paste codes 5 times into different activities. I am not sure if this is the right way…
You cannot “include” an
Activityto anotherActivity. Since yourActivityhas a basic functionality that all your otherActivitiesuse, you could have all yourActivitiesextend this basicActivity.The best way though for you would be to use
Fragmentsand the compatibility library.Regarding layouts, you can have reusable ones and import them to your current layout using
include.Hope this helps!