Skip to content

Content Tagged "android"

Page 4 of 6

Content Tagged "android"

NullPointerException - getInstrumentation().getContext()

March 11, 2015Category: Software
Here's a beginner mistake... The following code: Throws an exception: Attempt to invoke virtual method 'android.content.Context android.app.Instrumentation.getContext()' on a null object reference It took me some time to find out why: getInstrumentation() returns null in the constructor :) The…

Android Studio: Change the Cache Location

February 19, 2015Category: IT
Note: This is an updated article to reflect the stable release of AS. If you are looking for the old one, please see here . Android Studio (AS) creates a local directory .AndroidStudio to cache its own data. In most environments, this is acceptable. However, the size of the directory can easily…

Git Tagging a New Version

February 5, 2015Category: Software
Here is my way of generating version numbers of an application: The version number convention is: Major - a major version represents fundamental changes to the application, important feature(s) etc. Minor - a minor update means new feature extensions (e.g. adding new visual effects to an app) or…

List Alarms in Android

January 21, 2015Category: Software
The other day I thought it would be a good idea to list set alarms in android, so I whipped up the following code: Its idea is that we iterate through the alarm clocks set by the AlarmManager. This works quite OK, but it doesn't show periodic alarms :(, so it's of no immediate use to me. Therefore…

Decoupled Analytics

January 8, 2015Category: Software
While writing my first app, I've decided to try some analytics services. The most obvious one is, of course, Google Analytics (well, it's an android app after all!). Then, I found out that other services can provide analytics too, like Mixpanel . Unfortunately, most code I found online advocates…

Add a Toolbar to a PreferenceActivity

January 6, 2015Category: 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…

Make Dialogs Obey Your Material Theme

December 18, 2014Category: Software
Material design is nice. Flat, with well determined contrast rules... and most applications I've seen look excellent. I wanted my application to loon nice too and it does (well, almost right now :) ). One thing that is not in line is the dialog style. If you're here, you know that if you only set up…

Launch a timed service - Strategies

December 17, 2014Category: Software
An app I am writing at the moment needs to have a periodic timer, i.e. a way to run a bit of code at regular intervals. After digging through different sources, I've found two recommended patterns to code such behaviour: Using a periodic alarm: Android has the concept of periodic alarms (think an…

Split a Gradle Build File

November 30, 2014Category: Software
TL;DR: If you can, use ext {} with constants (hash). You can do call pointer things too! In the past days I've been trying to add some functionality to my Gradle build file so the version would be determined from the git tag. I've found this excellent entry showing how to get the actual string. My…

Android Dimensions - Pixels, DIPs...

October 16, 2014Category: Software
Building a mobile application is generally fun. New technologies, things to think about like memory constraints and threads... However, one thing that bugs me is a clear indication on how to build pixel perfect apps. IOS has a limited number of resolutions, plus their strategy is "normal size" or…
PreviousNext

All tags