Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70762

Does the Gyroscope plugin work in the Android emulator?

$
0
0

@greenie2600 wrote:

Title says it all. I’m successfully injecting Gyroscope into my page component, and I’m subscribing to this.gyroscope.getCurrent() and this.gyroscope.watch() without errors – but the subscriptions never detect any events.

The emulator has a screen for adjusting the orientation of the virtual device, complete with a fancy 3D representation of the phone – so I would expect this to work.

My code:

import { Component } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';

import { Gyroscope, GyroscopeOrientation } from '@ionic-native/gyroscope';

@Component({
    templateUrl: 'hardware-integration-sensors.html'
})
export class HardwareIntegrationSensorsPage {

    private gyroscope_subscription: Subscription;

    constructor(
        private gyroscope: Gyroscope
    ) {}

    ionViewWillEnter(): void {

        console.log('subscribing to gyroscope stuff');

        this.gyroscope.getCurrent().then((orientation: GyroscopeOrientation) => {
            console.log('gyroscope.getCurrent() fired', orientation); // this never happens
        });

        this.gyroscope_subscription = this.gyroscope.watch().subscribe((orientation: GyroscopeOrientation) => {
            console.log('gyroscope.watch() fired', orientation); // this never happens
        });

    }

    ionViewWillLeave(): void {
        this.gyroscope_subscription.unsubscribe();
    }

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>