Python: Detect Android
Solution 1:
You can do this with Kivy
from kivy.utils import platform
if platform == 'android':
# do something
EDIT:
As I said, I cannot use any 3rd party libs
Take a look at how Kivy implemented it.
def _get_platform():
# On Android sys.platform returns 'linux2', so prefer to check the
# presence of python-for-android environment variables (ANDROID_ARGUMENT
# or ANDROID_PRIVATE).
if 'ANDROID_ARGUMENT' in environ:
return 'android'
Solution 2:
from os import environ
if 'ANDROID_BOOTLOGO' in environ:
print("Android!")
else:
print("!Android")