java - Call getFragmentManager() without extending Fragment -


I have a class that should handle databases in my Android app when the database changes, then I display information from frogment I want to update the piece to do. My approach has been to give a tag to the piece and find the piece with the following code:

  FragmentManager manager = getFragmentManager (); Piece slice = manager.findFragmentByTag ("schedule"); If (example of a piece of timetable) {ScheduleFragment fr = (ScheduleFragment) piece; Fr.scheduleUpdated (); }   

However, as long as my database class is not an extension of the piece, the compiler is refused to recognize getFragmentManager () . There is no point in expanding this section for me, because the database class is not a piece, but there is a simple helper class for managing the database. Is it possible to get reference to my piece without expanding the piece? Or is it bad behavior and should it be done in any other way?

Besides, is it possible to get reference to the piece from a static method?

Try using the local broadcaster manager. For more information about localBroadcast Manager , when the database changes the intent of a broadcast, register this "schedule" piece and you can handle database changes.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -