Now open your Java file and use the code below. To enable action on the click of a hardware button, onKeyDown is a method which is invoked whenever we click on any hardware button. This method overrides the original method and it is invoked first. We can display every code of the hardware button which is clicked by user by simply displaying the keycode value in a given method before the 'if' condition. The code of the android Java file is given below with explanation:
Now run your project and test application. If you have any doubts please comment. Share and help all android developers.
★ Enable and Disable WiFi
★ Enable and Disable Bluetooth
★ Get Latitude and Longitude of the current Location
★ Use Sensor | Motion detection
★ Convert Text to Speech
★ Use Shared Preferences