Comments (5)
I am getting the same error here NullReferenceException and I am using it in Xamarin Forms
Is there a solution ???
CurrentOrientation is null
from xamarin.plugin.deviceorientation.
The issues also arises regulary for several of our customers (According to AppCenter Crash Reporting). Therefore, unfortunately we are not able to provide a reproduction. Does anyone have some clue what could possibly be the cause of this issue?
from xamarin.plugin.deviceorientation.
@thisisthekap Could you please provide some information:
- Which version of Xamarin.Forms do you use?
- Which platform?
from xamarin.plugin.deviceorientation.
@wcoder Currently we are using Xamarin.Forms 4.6.0.726
Here a list of Android devices and OS versions where we detected the issue:
Device | OS Version |
---|---|
F11 Pro | 9 |
Galaxy A40 | 9 |
Galaxy A50 | 9 |
Galaxy A7 (2018) | 9 |
Galaxy J2 Prime | 6.0.1 |
Galaxy Note5 | 7.0 |
Galaxy Note8 | 9 |
Galaxy S10 | 9 |
J8 | 5.1 |
Le Max2 | 6.0.1 |
M6 | 7.0 |
Mate 20 | 9 |
MI 8 Lite | 9 |
Mi A2 | 9 |
P20 lite | 9 |
VIBE X3 Lite | 6.0 |
Edit:
The issue was never detected on iOS devices.
from xamarin.plugin.deviceorientation.
I experienced the same issue using Xamarin Forms v4.7.0.968 but discovered this line CrossCurrentActivity.Current.Activity = this;
within the protected override void OnCreate(Bundle savedInstanceState)
MainActivity.cs file for the Android project. This requires the namespace using Plugin.CurrentActivity; . This solved the issue for me and the null reference error no longer appeared when I attempted to force a specific page, in my shared project, to only utilize portrait mode protected override void OnAppearing() { base.OnAppearing(); try { if (Device.Idiom == TargetIdiom.Phone && CrossDeviceOrientation.IsSupported) CrossDeviceOrientation.Current.LockOrientation(Plugin.DeviceOrientation.Abstractions.DeviceOrientations.Portrait); } catch (Exception) { //TODO: log exception } }
P.s. ensure you have the nuget package installed for each project. Xamarin.Forms sample
from xamarin.plugin.deviceorientation.
Related Issues (20)
- Landscape and Portrait switched in Android HOT 3
- LockOrientation not working on tablet HOT 3
- Is there any way to prevent the orientation change? HOT 8
- App crashes when I lock orientation to PortraitFlipped HOT 10
- How can I set to default the orientation of the App to Landscape? HOT 2
- Orientation lock does not work on iOS HOT 4
- Comparing orientations? HOT 4
- Support for NETSTANDARD 2.0 HOT 1
- Please add Fullscreen plist value requirement to documentation
- iOS NuGet still references .net standard 1.6
- Android: Cannot access a disposed object. HOT 3
- ios: after unlock, orientation doesn't restore normal value. HOT 1
- CurrentOrientation is reversed on some Android tablets
- Where is v2.0
- Add SetCurrentActivityResolver + Remove dependency to Plugin.CurrentActivity
- Build warning: Using a deprecated debug information level.
- Check/port to support MAUI HOT 3
- Possible to use lib for changing orientation iOS HOT 1
- NullReferenceException on Android HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xamarin.plugin.deviceorientation.