getSystemServices is undefined when called in a Fragment?

前端 未结 7 1830
醉酒成梦
醉酒成梦 2020-12-08 18:59

I want TextViews to display the sensors readings in a Fragment. When trying to initialize the SensorManager the getSystemService

7条回答
  •  难免孤独
    2020-12-08 19:10

    sensorManager = (SensorManager) 
    requireActivity().getSystemService(Context.SENSOR_SERVICE);
    

提交回复
热议问题