java.lang.IllegalStateException: Fragment not attached to Activity
问题 I am rarely getting this error while making an API call. java.lang.IllegalStateException: Fragment not attached to Activity I tried putting the code inside isAdded() method to check whether fragment is currently added to its activity but still i rarely gets this error. I fail to understand why I am still getting this error. How can i prevent it? Its showing error on the line- cameraInfo.setId(getResources().getString(R.string.camera_id)); Below is the sample api call that i am making. SAPI