Return the handle to a system-level service by name. The class of the returned object varies by the requested name.
1. In the MainActivity.java file, Get the Context.SENSOR_SERVICE and save to a string named svcName.
2. In the onCreate method, Declare a SensorManager named mySensorManager.
3. In the onCreate method, add the following line. This will get a reference to the SensorManager saved to mySensorManager.
mySensorManager = (SensorManager)getSystemService(svcName);
4. Compile and run!
Next Recommended Article:
Resources:
Professional Android 4 Application Development by Reto Meier , pg 482
http://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String)
mySensorManager = (SensorManager)getSystemService(svcName);
4. Compile and run!
Next Recommended Article:
Resources:
Professional Android 4 Application Development by Reto Meier , pg 482
http://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String)