java.lang.IllegalStateException: Fragment not attached to Activity

前端 未结 12 1155
名媛妹妹
名媛妹妹 2020-11-28 02:28

I am rarely getting this error while making an API call.

java.lang.IllegalStateException: Fragment  not attached to Activity

I tried puttin

12条回答
  •  [愿得一人]
    2020-11-28 02:47

    this happen when the fragment does not have a context ,thus the getActivity()method return null. check if you use the context before you get it,or if the Activity is not exist anymore . use context in fragment.onCreate and after api response usually case this problem

提交回复
热议问题