4 articles Android

Android Fragments and Transactions

Problem Sometimes it is confusing how fragments work in Android and interesting side effects like: Why have Fragments empty constructors? Why shouldn’t I pass state variables like they are? Why do I need this Fragment transactions? What does addToBackStack mean and do I need it? Why is sometimes the Activity null in my fragment? Overview…

Android Bind Service to the Application cross Activities

The Problem Sometimes we want to bind an Android Service in our activities and wrap inside e.g. our communication to our backend. Now the problem arises when we unbind it again. As usually if we change activities we want this service to survive and be in the very next activity. As soon as we close…

Android show Keyboard by default

Problem Sometimes we the Keyboard doesn’t show up by default if we e.g. open a dialog and request the focus for an input element. Even following the default tutorials doesn’t really help. As soo here some samples how it will show up. Solution Show Keyboard in Dialogs / DialogFragment Usually the solution the the Android…

Android Global Exception Handler

Background / Motivation Sometimes it is quite useful to handle/catch exceptions in a central handler. Typical samples are: Handle Authorization problems e.g. with your backend Central dispatching of these error to an Exception Collector like Crashlytics (ur just send an email) Just show a message dialog to the user Implementation Just creating an Exception is…