Android - onAttach(Context) not called for API 23

前端 未结 7 912
离开以前
离开以前 2020-12-08 05:46

I\'ve updated the SDK to the latest version (API 23) and the onAttach(Activity) method for fragment is deprecated. So instead of using that method, now I\'m usi

7条回答
  •  囚心锁ツ
    2020-12-08 06:41

    After I read your answer @David Rauca I think the second one can solve my problem. But when I look into the source code. I found that actually, onAttach(Context context) do nothing on Android M, just called the old method.

    As a solution:

    @SuppressWarnings("deprecation")
    

    Just add it into the old method is the best solution.

提交回复
热议问题