Hello.
In Pydroid 3, you can't detect your phone direction(portrait or landspace) with traditional methods. Pyjnius isn't working, because Pydroid 3 can't print Java code in Terminal. Kivy is working, but only with window.
But you can detect this!
Python's Shutil module can detect terminal size:
from shutil import get_terminal_size as size
print(size().columns) # Width, example: 60
print(size().lines) # Height, example: 33
Now rotate your phone to landspace and print this again.
Print is different😳! Example, 122 and 8! Android don't lock phone orientation 100%!!!!
Now, divide this numbers. Result:
≈1.07<2 in portrait
≈15.25>2 in landspace
YES! This's detect!
from shutil import get_terminal_size as size
def portrait():
return size().columns/size().lines<2
while True:
print(portrait())
If you rotatw the phone, result will change!!!!
Top comments (0)