How to emulate a gyroscope in an Android Emulator
Gyroscope is newly supported in the Emulator of Android Studio 3.0, released to the Canary Channel on 5/17/17. Note that (as of today) Android Studio 2.3.3 is the latest official (i.e. "stable") version. Here is how you setup the Preview Version of Android Studio, which can exist concurrently with the official version.
Note that running the emulator out of the box won't work, as it's not a recent enough version:
You need to follow the 'change your update channel' steps in the latter link: select File > Other Settings > Default Settings and update from the Canary Channel:
Note that while running a Virtual Device with Android 7+ (aka API 26) did show Gyroscope output in the emulator's Virtual Sensors (within Extended Controls), it does not (at least yet) send that output to the virtual device; to actually see the environment in the sample app move as I moved the phone, I had to use Android 7.1.1 (API 25).
(Thanks to @jamal-eason for the protip!)
PREVIOUS (6/12/17):
As of the date of writing the release version of the Android Emulator (in Android Studio 2.3.3) does not offer Gyroscope support.
While the documentation referenced by @Nesski suggests this, I offer the following as proof:
The Android SDK's Virtual Reality getting started demo is the game called Treasure Hunt. Here is what it looks like when played on a phone. Notice that the camera moves as the player looks around.
Of the handful of devices compatible with the Google Daydream - because they contain an internal Gyroscope - Android Studio's AVD Manager offers only two of them: the Pixel and Pixel XL. I downloaded two virtual devices for each of those phones so that I could run the latest two Android versions (7.1.1 and 8.0) on each device:
I ran each device in the Emulator, and got similar results: press CTRL + SHIFT + C (on Windows) to bring up the Extended Controls, and you'll be able to test the phone's Virtual Sensors:
Using its Rotate controls, you'll notice that while there is Accelerometer output, Magnetometer output, and Rotation output, there is no Gryroscope output. You can rotate the phone as if you were looking around, but the game's camera view does not change as the phone is moved.
While this sad reality is unfortunate, I do, however, hope and expect Android to add Gyroscope support to the emulator in the future as more developers jump on the Google Daydream Virtual Reality bandwagon.
testing accelerometer in android
You can try this to emulate sensor data in the emulator:
http://code.google.com/p/openintents/wiki/SensorSimulator
How do I simulate rotating the device with Android emulator?
you can use KEYPAD_7, Ctrl-F11 ,KEYPAD_9 or Ctrl-F12 to move to the next orientation
Related Topics
How to Animate Marker in Android Map API V2
Android - Multi-Line Linear Layout
Could Not Access the Package Manager. Is the System Running While Installing Android Application
Spinner:Onitemselected Not Called When Selected Item Remains the Same
App Completely Restarting When Launched by Icon Press in Launcher
Speed Control of Mediaplayer in Android
Quality Selector for Exoplayer 2
Debug Native Code in Android Library
How to Add Crosswalk Webview in My Own Android Library Module
Aidl Is Missing Android Studio
How to Do Circular Scrolling on Viewpager
Set Font for All Textviews in Activity
Cordova Android Requirements Failed: "Could Not Find an Installed Version of Gradle"
How to Send Notification to Specific Users with Fcm
Need to Disable Expand on Collapsingtoolbarlayout for Certain Fragments
How to Take Multiple Photos Before Dismissing Camera Intent
Trying to Uninstall_Shortcut But Shortcut Won't Go Away
Multiple Count Down Timers in Recyclerview Flickering When Scrolled