How to get the MAC address on Android

(A test project can be found on github)

Since you can easily get confused with the many permissions provided by google, let me show you two ways to get the mac address on android. The first approach would be to use the WifiManager.getMacAdress().

However there are Disadvantages:

  • Device should have Wi-Fi (where not all devices have Wi-Fi)
  • If Wi-Fi present in device should be turned on otherwise does not report the MAC address
  • And the suspicious permission ACCESS_WIFI_STATE

Another approach is the use the NetworkInterface.getHardwareAddress()

Disadvantage: uses permissions too, although they are required for your app to access the internet anyway and more likely commonly known to the end-user.


Carring about permissions can be a pain in the butt there are even other ways if you just want identifying app installations, too.

Android libgdx ShaderAssetLoader & StillModelLoader

I totally love how libgdx brings a lot of interfaces for your application to connect to the graphics library. For instance the asset manager is really thought through well in particular. It has some really useful methods like Assets.manager.getProgress(). Especially since you can easily write your own asset loader and be able to utilize the loading progress in your app.

1) Simply add your loader to the asset manager at some point.

2) load your assets at required places, e.g. loading screen
(Note: SHADER_PHONG = “data/Graphics/Shader/Phong”; and MODEL_TEAPOT = “data/Graphics/Shader/teapot.obj”)

3) get your shader or model wherever you need them

4) free the resource by unloading when you’re done with them (e.g. disposing your app; changing screens)

That’s the shader asset loader for loading custom shaders in libgdx. (Note: adapt your extensions)

And here is the StillModel loader for loading 3D meshes:

Conclusion: assets are handled well in libgdx :D

Android: Saving Screenshots in OpenGLES

1) Get your helper methods:

2) get a queue ready

3) add new filepath the the queue via e.g. events:

4) IMPORTANT! save the screen at the end of the opengl render process. (Note: If try to capture somewhere in the middle you might end up with a black screen or any other funny effects.)

DroidCon Wednesday 10-04-2013 at Kosmos Berlin

11:15 Dos and Dont’s of Android UI by Juhari Lebtimäki (SnappT)

He talked about a lot of generic and common sense design guidelines. Which you probably know all along by books like “Don’t make me think” by Steve Krug just applied to on android. He gave a couple of recommended principles like

  • designing for mdpi resolutions (1dp = 1px = mdpi) and scale from there (android dimensions)
  • use conventional icons when appropriate
  • use 9-patch
  • action bar on top and not on bottom
  • naturally swipe between slides (instead of teleporting by tabs)
  • errors on top like google play app (leats surprising)
  • be careful with tutorials, instructions are bad, try to be self-explanatory
  • popups are bad, because it interrupts use flow for no real reason and
  • use notifications instead, android did a good job at that
  • first time start like evernote for complicated usages
  • be conistent with the navigation as much as possible
  • let the user use the app without login for the first start even with restricted functionionality, avoid invoking the user to feel like doing a blind bargain
  • don’t hide the status bar, your app is not the reason the user has his phone!
  • customization is not an alternative to design
  • user tests for obvious reasons.

Well nothing really new but it was a well hold presentation nonetheless.

11:40 ProGuard, Optimizer and Obfuscator in the Android SDK by Eric Lafortune (Saikoa)

He basically gave an overview about what proguard does. That it is shrink, optimizes and obfuscates the final release versions of your android apk. Turns out it is a rather powerful tool. I’m using it for protecting code and removing logging so far. There is also a commercial version called dexguard.

12:20 Tracking User Behaviour Creatively by Kiana Tennyson (Manheim)

Google Analytics how-to tutorial kind of talk. Let’s hope people with bad intentions don’t abuse it.

12:20 Build your own app analytics tools by Matthais Huber and Monica Tudora (1&1 Internet)

Monica showed some simple code examples how to track user input and publishing it to private servers in order to improve the app with ACRA and heatmaps. Probably bigget advantage of that approach is that you don’t need to publish anylitic statistics on public and / or 3rd person services. Also she made me aware of how easy it is to create own analytic tools. It can be simple and still can be useful.

13:00 LUNCH

14:00 Firefox OS by Andreas Gal (Modzilla)

It’s quiet interesting concept of having an entire OS being programmable by html, js and css. Sadly very presented too quiet.

14:45 Re-Engineering the Facebook SDK by Connor Treacy (Facebook)

Connor Treacy presented the latest Facebook SDK 3 changes compared to 2. The sdk is easier to use now, and probably easier as well.

15:25 Real Time High Performance Multimedia Systems on Android by Prashant Dixit (Ittiam Systems)

slides will follow…

16:35 Biitstrap Continues Testing for Android in 5 Minutes by Andreas Lüdeke (TestObject)

http://www.cloudbees.com/#slide-2 and http://testobject.com/ in toolchain

DroidCon Tuesday 9-04-2013 at Kosmos Berlin

11:15 Efficient Android Threading by Anders Göransson (Jayway)

Anders gave a nice overview with code examples about multiple ways to do threading on android. Especially the use cases were distinguished rather well.

11:55 Incorporating touch feedback in your apps by Peter van der Linden (Immerson)

Very good and entertaining talk about the haptic feedback sdk. (demo app in android market) I’m definitely going to test in the near future. Because it looks easy to use but still powerful to give vibration feedback with your android device. And a tweet about it got me a stylish android hat :D

12:35 Libgdx game development framework by Alexander Fröhlich and Thomas Madsen (Andlabs)

Well it was kinda like the same talk as yesterday. You had the feeling they only used it for like one day and not went any further. Maybe it’s the restricted time limit of half an hour for the talk. At any rate. I didn’t learn anything new that I couldn’t have learned within a few tutorials myself. Except maybe the recommendation about tile map editors – like tile map editor – and the Physics Body Editor, especially the last one looked really promising for future boxed2d projects. At least the presentation has been done with prezi so the slide transitions weren’t boring. xD

13:15 LUNCH ^_^ <3

14:15 Designing Accessible Android Applications by Sonia Sharman (Google)

Sonia basically advertised to use android build-in functionality like AccessabilityEvents and AccessabilityServices in order to support the use for sight or else handicapped people. It reminded of accessibility guide lines for websites. For instance, minimize chatter, provide feedback, label UI elements / tagging and grouping view elements properly in order to help text to speech programs to be actually useful. I think it’s very important but I can also imagine to most of the developer it will be last on their checklist since their android apps are not needed to be tagged like websites do for SEO reasons. She also mentioned talkback and tripple-tap-zoom. Further informations can be found in the official android documentation.

Also quiet interesting is the Google I/O 2012 talk about it:

15:00 Improving Android Experience by Pavel Lahoda (Actiwerks)

Pavel talked about how to improve the UI. He suggested that android developer can learn from web developers in order to support multiple screen resolutions and layouts for instance using responsive design. Some mentioned solutions were standout – floating windows, fly-out menu, actionbarsherlock. He also pointed out that the native android sdk doesn’t provide enough functionality for that purpose. Not for all devices and all screen resolutions anyway.

15:40 Location and vision based AR by Simon Heinen and Mostafa Akbari (Bitstarts)

Well regrettably this was merely an advertising show off bitstars AR SDK.  They basically use a JMonkey Engine to render, GPS (>10-30 meter precision), WIFI, Step detection (> 5 meter precision) and SLAM (>1 centimeter precision) for getting precise locations. At any rate augmented reality is cool especially without markers and I’m looking forward for awesome applications in the future.

16:50 Unifying Callbacks in Android by Matt Brenner (UnME2)

Matt introduced his cooked up EventConsumer Pattern. Which seems to be a way to minimize the boilerplate for events. Although based on the reaction by the audience it didn’t quiet convince everyone. I think it’s a good idea to minimize doubled code though.

17:30 Understanding the GPU to write better code by Guillem Vinals Gangolells (Imagination Technologies)

The last talk today was quiet interesting. Rather low level but a lot of generalised recommendation. Mostly Guillem talked the graphic pipeline for OpenGL on android. I’m going to put his presentation online as soon as they publish it.


Today were far better and mostly way more organised talks. I learned quiet a few new things for which I’m grateful. For instance the haptic sdk, the physics body editor, standalone, fly-out actionbarsherlock are worth looking into. I would have wished for deeper information (not something i can read up in first timer tutorials) at the libgdx talk and less vacuum-cleaner salesman feeling at the android augmented reality talk. Other than that it was well worth attending.

DroidCon Barcamp 8-04-2013 at Kosmos Berlin

This is going to be a short recap for myself about the DroidCon 2013 in the Kosmos Berlin. In deepest respect I thank every presenter for their hard work who took the time to share their knowledge and insights. The following is purely my observation and might be very subjective. If anything appears to be offending please read it as my personal opinion.

11:45 – Interaction and beyond – Wolter

He basically showed of a couple of different devices to develop for and encouraged everyone to think out of the box to get your application as appropriate as possible to increase the end user experience. For instance:

Nothing new in particular though.

12:45 – Libgdx Thomas

He gave a very brief overview about the high level layer of the framework and some components like the SpriteBatch, InputProcessors, how to get the deltaT value, and how to swap some screens. I was a bit disappointed, since I was – work related – looking forward for this talk in particular.

13:15 FOOD! ^_^ Well there was a very delicious all you can eat lunch buffet, which basically amortised  the 10€ entry fee* already. (*which got sponsored by my awesome employer, thank you very much Wooga <3)

14:15 – Push Notifications with Netmera / Android Software Craftsmanship

Well this talk was kinda boring, since the presenter only walked you through the process of using their service layer for using google cloud notifications. He didn’t give much insight or reasoning behind the steps he clicked through. Felt like something I could read up later in a tutorial. So I changed to: Android Software Craftsmanship. Which basically was a free highly unprepared discussion about the common ways to develop software. (not a bad thing in this case) It appeared to be consens for all of he participants to use the test-driven approach. Using version controle like git and svn and even use a continues integration development layer to not mess up things in the long run. If something is not automatable: use conventions and iterate over them so they don’t force outdated rules. Also to abstract layers like DAO-Pattern in order to test them more separately has been recommended. Another recommendation was to use integration and behavioural tests for obvious reasons.

The very most and interesting part for myself was to get to know code retreat. Which basically makes you start a project (possibly pair programming) and work on it for 45 min and then throw every code base away in order to start over the same project again. The goal is not to finish the project but to approach the same problem 6-7 times. Usually differently and most likely better. (e.g. Coneway’s Game of Life) Personal I think it’s a pretty cool and fun idea to improve your own skills.

15:00 Mobility Android

Basically they gave an introduction about their flat search app and some thought process behind certain layout questions. They also opened a discussion on how to improve it even further. Turns out there is always someone with a bright idea to about everything. I think these kind of discussions are very worthwhile attending since you won’t forget the reasons for solving problems in a certain kind of way.

15:45 Reverse Engineering Ingris

Dirk Jäckel put his presentation online. Well – as the title states. If you’re into these kind of stuff it’s worth reading. For me however it was a bit too unrelated to everything I’m doing. So I’m not going into details about that one.

15:45 NFC in Games by Hannes Breul

Since the reverse engineering talk was shorter than expected I joined that talk at the middle. He was giving a good summery about where NFC could be used and about it’s strengths and weaknesses. For instance it can be used for location based games, crowd games with single/multiple locations, since it can be used for transmitting content. I didn’t quiet get all the details, but it sounded quiet interesting. I’m going to link his presentation, as soon as he puts it online.

16:15 Sascha Pallenberg from MobileGeeks opened a discussion about the awareness of the public imagine from younger generations on the internet. And that there should be some sort of education for it. So young people don’t put content online which could ruin their job carrer years ahead before actually applying. Which is troublesome since the knowledge about teachers and younger generations seems to be reverse. Pupils might know more about key technologies than teachers but are not entirely aware of the consequences of their public and transparent internet image and how hard it is to erase unfavourable content. It turned out to be some quiet interesting discussion to follow for one because of Sascha’s well communication skills and for the other because the very different opinion about how transparency could be interpreted in the near future by HR people.

17:15 What to consider when teaming up with a co-founder.

Was quiet interesting as well. Especially the consens to write everything down before starting anything. Better be safe than sorry I suppose.

17:45 Demo/Judgment

Basically a couple of startups showed off their latest android app and were looking for feedback, new designers, developer, business people to join their team or to find new investors. I’m gonna talk about this later when the judgement people are done judging and put their stuff online.


Monday the Barcamp was probably designed for people who haven’t done much with android yet I suppose, since it was rather surficial for my taste. Anyway I got to know some new people which was totally worth participating. It’s all about the people there after all. And the food was quiet enjoyable, which usually convince me to recommend it. :D

How to boost android canvas performance with a buffered Image

When it comes to drawing to canvas on android one very big performance boost can be gained by using a buffered bitmap image. The idea is to draw lines to a bitmap. And then draw the bitmap to the screen.
This approach avoids unnecessarily redrawing elements that has been drawn already multiple times.

1) Create a bitmap in your view.

2) Remember all touch events.

3) Process all touch events. (Draw lines or something)

4) Draw to buffered bitmap image.


5) And finally draw the buffered bitmap image.

Bonus: invalidate canvas only around finger area and only every 90 milliseconds.

See also

Performance in 2D Canvas App / Game on Android and Traceview War Story

Doodle Drawer – Brushes

At my Doodle Drawer app, I’ve played with a couple of “brushes”. The idea is to treat the connection lines differently.


Basically the difference is that the line connections are drawn closer or further away from each line based on the formula of Harmony.

The ‘shaded brush’ looks like this:

The sketched brush looks like this:

And the ‘fur brush’ looks like this:

Android: How to get round stroke corners in canvas

When you draw a path with a bigger line stroke width, you might notice uggly edges.

android canvas no round stroke corners no round stroke corners

In order to get them round you simply need to change the stroke join to round. Here are some default settings I’m using in my Doodle Drawer app.

At the end it should look like this:

round cornersround stroke corners

Doodle Drawer

Inspired by Harmony from Mr. Doob (Ricardo Cabello) I made a little app called ‘Doodle Drawer’. The basic idea  for some brushes is that it connects lines that has been drawn already and in case they’re close enough.

doodle drawersilly doodle