@capacitor/screen-orientation not working on Android

  Kiến thức lập trình

Using @capacitor/screen-orientation 5.0.7 with the listener “screenOrientationChange” works fine on iOS but not on Android. Any ideas why?

Android stays in portrait and does not display the console log “Orientation changed”.

ScreenOrientationCap.addListener('screenOrientationChange', (event) => {
      console.log('Orientation changed:', event);

      if (event.type === 'landscape-primary' || event.type === 'landscape-secondary') {
        console.log('landscape')
        this.landscapeOrientation = true;
        this.getMembershipPackage();
      } else {
        console.log('portrait')
        this.landscapeOrientation = false;
      }
    });

It seems to add the listener fine:

LEAVE A COMMENT