I want to enable rotation only in tablets on Android. I Created bools.xml with this code
<resources>
<bool name="portrait_only">false</bool>
</resources>
and put in MainApplication.java
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...
@Override
public void onCreate() {
if(getResources().getBoolean(R.bool.portrait_only)){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
super.onCreate();
}
}
}
I get error: cannot find symbol setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Application doesn't have setRequestedOrientation() method — Activity does. So you should move the code into your BaseActivity onCreate().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With