Yoda
Yoda

Reputation: 18068

How to get instance of SensorManager

I want to get instance of SensorManager. What should I write instead of SENSOR_SERVICE below? If it is name of registered service what add to Manifest.xml?

mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);

I have been using code from here: http://developer.android.com/reference/android/hardware/SensorManager.html

EDIT: There is no such method as: getSystemService(....);

EDIT2: Will this do: ctx.getSystemService(Context.SENSOR_SERVICE);?

Upvotes: 0

Views: 508

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93542

All Context's have that function. You need to either call it in a Context class (Activity or Service) or call it on a reference to one (context.getSystemService())

Upvotes: 1

Related Questions