It might feel stupid question to ask, but I would like to understand possible way of implementations!
My application is location based. At SplashScreen
of application I fetch the user location (each time) using GoogleApiClient
. It also implements ResultCallback<LocationSettingsResult>
and LocationListener
. Everything works great here.
After this, I sign up the user with fetched location. On successful sign up, I take user to MapFragment
. Now this fragment again implements GoogleApiClient
, ResultCallback<LocationSettingsResult>
and LocationListener
.
Now my question is can I avoid this code repetitions in my both activities?
As far my knowledge, I can have a parent Activity
/Fragment
with all these location based Interface
implementations and extend the same in SplashScreen
activity and MapFragment
Is it a good practice to do so? Or is there any other better way I can do this?