Start an activity from a fragment

mFragmentFavorite in your code is a FragmentActivity which is not the same thing as a Fragment. That’s why you’re getting the type mismatch. Also, you should never call new on an Activity as that is not the proper way to start one. If you want to start a new instance of mFragmentFavorite, you can do so via an Intent. From a Fragment: From an Activity If you … Read more

Android Fragment onAttach() deprecated

Activity is a context so if you can simply check the context is an Activity and cast it if necessary. Update: Some are claiming that the new Context override is never called. I have done some tests and cannot find a scenario where this is true and according to the source code, it should never be true. In … Read more

How to implement OnFragmentInteractionListener

Answers posted here did not help, but the following link did: http://developer.android.com/training/basics/fragments/communicating.html Define an Interface For example, the following method in the fragment is called when the user clicks on a list item. The fragment uses the callback interface to deliver the event to the parent activity. Implement the Interface For example, the following activity … Read more