How to restrict tablet screen orientation?
found the answer, an app that will run just one time.

create an app and add a permission to it's manifest to write_settings &amp; listen-to-boot :

&lt;uses-permission android:name="android.permission.WRITE_SETTINGS" /&gt;
&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;


then make a receiver class which extends BroadcastReceivertype, with the fowlloing permissions:

    &lt;receiver android:enabled="true" android:exported="true" 
        android:name="com.example.BootCompletedReceiver"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED"&gt;
        &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                &lt;action android:name="android.intent.action.QUICKBOOT_POWERON" /&gt;
                &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;


then in the onReceive() method of the receiver class:

ContentResolver contentResolver = context.getContentResolver();
        //To handle device rotation 
        Settings.System.putInt(contentResolver, Settings.System.ACCELEROMETER_ROTATION, 0);
        Settings.System.putInt(contentResolver, Settings.System.USER_ROTATION, Surface.ROTATION_90); // 0 for default, then 90, 180, 270


Then run this app just one time to write that permissions to the system, and then you don't need it again.