Add a Toolbar to a PreferenceActivity

Posted by in Software

When trying to move a playground to Material Design, I stumbled upon the new Toolbar widget, which is supposed to replace the ActionBar (well, that’s my understanding from all the posts I’ve read). Thing is, the Toolbar is designed to be added to an Activity. To do that, the Activity class has a new method public void setActionBar (Toolbar toolbar) since API 21. The problem Adding the Toolbar to an activity is easy and documented in all sources implementing material design on github. However, Adding an action bar to a PreferenceActivity, is nowhere to…read more

Android: Make Your Notification even Sticky-er

Posted by in Software

In my previous post, I’ve expanded things to make a notification sticky. This worked in my tests until yesterday, when I’ve found a new case where my notification would go away: < ol> Build an sticky notification as per the two previous posts Activate the notification – this will trigger the activity to be displayed on screen. The notification will remain shown Activate the notification again – this will make the notification go away, because the activity is already on screen < ul> I’ve tried triggering the notification in onCreate()read more

Braindump: Save State on Activity Rotation Lifecycle – Android

Posted by in Software

Now I’m trying to write a (more complex) Hello World application for Android following a bunch of internet resources. I’ve read that an Activity has a life cycle (create/start/stop/resume/pause/destroy). This makes sense, because most UI elements (also in other frameworks) can be viewed as having lifecycles. I found out that the activity gets destroyed and re-created every time the screen is rotated. At a first glance, it might seem a bit surprising (particularly for people coming from desktop or web UI), because the tendence is to recycle widgets & stuff….read more