Download the New LearnVern Android App and enter Lucky Draw to win Free Certificate
If you are facing any issue in playing video please use Firefox browser.
Example of Sensor in Android Application
In today's video we are going to see an example of Sensor in Android.
For this we will post take one relative layout in our activity_main.xml file and also set basic properties to the Text view.
Now we will open MainActivity.java file and code inside it.
public class MainActivity extends Activity
SensorEventListener sel=new SensorEventListener ()
public void onSensorChanged(SensorEvent event)
public void onAccuracyChanged(Sensor sensor, int accuracy)
public void onCreate(Bundle savedInstanceState)
After that we will pass 3 different content, sm, accText, and list.
The condition which we need to set now is,
After coding all of this we will run our code. We see that our code runs successfully. By default the values of X,Y,Z is printed and as we rotate our phone the values get changed accordingly.
Have a friend to whom you would want to share this course?