New Blog Post

Android screen orientation

disable orientation change <activity android:name=”.MainActivity” android:screenOrientation=”portrait” tools:ignore=”LockedOrientationActivity”> Handling orientation state Saving instance state @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“ScoreKey”, mScore); outState.putInt(“IndexKey”, mIndex); } Retrieving instance state @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null){ mScore = savedInstanceState.getInt(“ScoreKey”); mIndex = savedInstanceState.getInt(“IndexKey”); } else { mScore = 0; mIndex = 0;…

New Blog Post

Android App Lifecycle

Code class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) Log.d(“LifecycleTest”, “onCreate”) } override fun onStart() { super.onStart() Log.d(“LifecycleTest”, “onStart”) } override fun onResume() { super.onResume() Log.d(“LifecycleTest”, “onResume”) } override fun onPause() { super.onPause() Log.d(“LifecycleTest”, “onPause”) } override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) Log.d(“LifecycleTest”, “onSaveInstanceState”) } override fun onRestoreInstanceState(savedInstanceState: Bundle) { Log.d(“LifecycleTest”,…

New Blog Post

Android Enable USB-Debugging

goto Settings > General > About phone > Software information and tap “Build number” seven times until it says “You are now a developer”  Goto Settings > General > Developer options and enable USB Debugging Drop down the notifications menu and click on “Tap for more USB options”. Most likely, the main title will say…

New Blog Post

JavaScript modules

<head> <script src=”../js/constants.js” type=”module”></script> <script src=”../js/script.js” type=”module”></script> </head> constants.js export const projects = [ “Project-A”, “Project-B”, “Project-C”, ]; script.js import {projects} from “./constants.js”;

New Blog Post

Telegram Bot with MicroPython

Motivation In my project Mailbox IoT ESP 32 Project I needed a Telegram bot to relay the messages. So here is a short tutorial Create TG bot Open Telegram Search for @botfather Start chat Send /newbot Pick a name Pick a username (must be unique) Receive credentials Chat with your bot Now you can search…

MicroPython uos package

When you are familiar with Python os and platform package You may wonder how to use it on ESP32 in MicroPython. Because this doesn’t work: >>> os.name Traceback (most recent call last): File “”, line 1, in AttributeError: ‘module’ object has no attribute ‘name’ >>> import platform Traceback (most recent call last): File “<stdin>”, line…

Using MicroPython on FireBeetle ESP32

Motivation In Fire Beetle ESP 32 Project I wrote about connecting the FireBeetle ESP32 with the Arduino IDE and writing a little C-style program. Another interesting approach is to use MicroPython. Installing MicroPython Install esptool To get MicroPython onto the board we use the esptool command line. Because we are in the Python ecosystem we…

Mailbox IoT ESP 32 Project

Motivation Out of curiosity I bought a ESP32 board to tinker with, but for almost half a year hadn’t got an idea what to do with it… But then! Project Idea The idea: Every time I get mail into my physical snail mail mailbox, the mailbox shall send a message via Telegram to my smartphone:…