Is it possible to get an object “FragmentManager” in “Service”? Is it possible to pass an object “FragmentManager” from “Activity” in the “Service”.
PS: Includes not officially supported features.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, sorry.
That would be an exceptionally bad idea.
If you wish for your service to update your UI, bear in mind that there might not be a UI. The user is welcome to press their BACK or HOME button to exit your UI, even while your service is running.
Also bear in mind that it might be a different UI. For example, when the user rotates the device from portrait to landscape, your activity (and fragments, by default) will be destroyed and recreated. Or, the user may tap on something that brings a different activity to the foreground, and that activity has its own fragments and manager.
Therefore, to have your service update your UI, you need to use a communications path that supports this sort of decoupled operation, such as:
LocalBroadcastManagerContentProvider, with activities usingCursorLoaderorContentObserverto be notified about data changes