React-native-orientation: addOrientationListener is not working!

Created on 9 Feb 2018  路  6Comments  路  Source: yamill/react-native-orientation

I followed every step mentioned for this lib.

But addOrientationListener is not working at all in ANDORID but works in iOS.
@yamill Please check this.

Most helpful comment

@sujay-bidchat How did you fix the issue? I am facing the same issue!!! Working fine on iOS but not on android. Can you share some code to clarify. Thanks

All 6 comments

Any solution?

@andfs That's my mistake, I had not implemented orientation listener methods in Android project. Its working fine.

@sujay-bidchat How did you fix the issue? I am facing the same issue!!! Working fine on iOS but not on android. Can you share some code to clarify. Thanks

don't forget to add this in your MainActivity.java

@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Intent intent = new Intent("onConfigurationChanged"); intent.putExtra("newConfig", newConfig); this.sendBroadcast(intent); }

@imranMnts

don't forget to add this in your MainActivity.java

@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Intent intent = new Intent("onConfigurationChanged"); intent.putExtra("newConfig", newConfig); this.sendBroadcast(intent); }

That didnt do it for me, returns an error when trying to run the app

@imranMnts

don't forget to add this in your MainActivity.java

@override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Intent intent = new Intent("onConfigurationChanged"); intent.putExtra("newConfig", newConfig); this.sendBroadcast(intent); }

That didnt do it for me, returns an error when trying to run the app

Which error ?

Did you add these lines:
import android.content.Intent; import android.content.res.Configuration; ?

Was this page helpful?
0 / 5 - 0 ratings