fragment by getActivity () Gets a null pointer Context

  Recently came across a very annoying problem when out of Bluetooth communication is to use activity in the Fragment method ,,, new activity always reported a null pointer.

  Solution:

         Call (activity) getActivity in Fragment of onAttach (Context context) method () can be solved;

 

  Haha, very simple. . .

Guess you like

Origin www.cnblogs.com/dmrbell/p/11316530.html