A developer's tool : Codota / Livecode

Written by Xavier Gouchet - 04 june 2014 - no comments

Codota is a website proposing Android code snippets on various subjects. Although they don't have much content yet, the idea seems great. Anyway I'm more interested in their new Chrome Extension : Livecode.

Codota Livecode

This extension will make all Android classes and methods clickable on Codota an Stackoverflow. Clicking will then display the official documentation of the class / method directly. This is just a great tool when you spend your time on StackOverflow !

A developer's tool : Screenshot Cleaner

Written by Xavier Gouchet - 02 june 2014 - no comments

When deploying an app on a Store, be it Google's Play Store or Amazon's, or any other, a developer needs to create goodlooking screenshots. And often, the screenshot is not as clean as it can, mainly because of the status bar, showing a low battery, or numerous icons (unread mails, social network notifications, ...).

Screenshot Cleaner

Screenshot Cleaner takes your screenshot and cleans the status bar, making your screenshots look professional.

Source : @francoisblavoet

Launch intents using ADB

Written by Xavier Gouchet - 15 may 2014 - no comments

Sometimes, you want an Activity or a Broadcast Receiver to listen for a specific intent, which is not always easy to test. There are some applications, like With Intent which let you declare and send an intent. But you then need to be outside of your app.

I just discovered that you can use ADB to send an intent to any device (physical or emulated). Here are a couple of sample command you can run in your shell (assuming your sdk/platfor-tools is in your path) to start activities.

# specifying the action and data uri
adb shell am start -a "android.intent.action.VIEW" -d "http://developer.android.com"

# specifying the action, mime type and an extra string 
adb shell am start -a "android.intent.action.SEND" --es "android.intent.extra.TEXT" "Hello World" -t "text/plain"

# specifying an explicit component name 
adb shell am start -n "com.example.application/.MainActivity"

And of course you can also start a service or broacast an intent

# specifying an explicit component name 
adb shell am startservice -n "com.example.application/.BackgroundService"

# specifying the action
adb shell am broadcast -a "android.intent.action.PACKAGE_FIRST_LAUNCH" -d "com.example.application"

You'll find all the options you can use in the Official Documentation.

Classified in : Tools - Tags : none

Android NDK tips

Written by Xavier Gouchet - 23 april 2014 - no comments

The Android NDK can get really powerful, but one of the few drawbacks is that the Android.mk configuration file must list the source files. And if your project contains too many files, it can get quite difficult to maintain. Here's a little tip to list the files in a JNI source trees that is more readable, and more maintainable.

Here's your default Android.mk file

   LOCAL_PATH := $(call my-dir)

   include $(CLEAR_VARS)

   LOCAL_MODULE    := hello-jni
   LOCAL_SRC_FILES := hello-jni.c foo/spam.c  foo/eggs.c foo/bacon.c bar/banana.c 


Assuming you have folders foo and bar inside your jni folders, each with many source files, here's how you can list all your sources. First create a sources.mk file in each subfolder, with the following code in it :

LOCAL_SRC_FILES += foo/spam.c  foo/eggs.c foo/bacon.c

Then modify the Android.mk file that resides in your jni folder like this ;

   LOCAL_PATH := $(call my-dir)

   include $(CLEAR_VARS)

   LOCAL_MODULE    := hello-jni
   LOCAL_SRC_FILES := hello-jni.c

   include $(LOCAL_PATH)/foo/sources.mk


My own Muzei extension : MuzeiDeezerAlbums

Written by Xavier Gouchet - 25 february 2014 - no comments

So, a couple of weeks earlier, Roman Nurik released an Android Live Wallpaper allowing other developers to create plugins. If you don't know it already, check it out, as well as the extensions.

As soon as it got out, I knew I wanted to play with this new toy, and it was not hard to get an idea of extension to do. As I work at Deezer, I thought "Hey, let's use album covers as wallpapers!". A little bit of code later, and here is my contribution to Muzei : MuzeiDeezerAlbums.


Albums displayed can be selected four different ways :

  • from Deezer's weekly selection, categorized by genres;
  • from your own selection of album covers;
  • from the last track you listen to with Deezer (if you don't have it, check it out here https://play.google.com/store/apps/details?id=deezer.android.app);
  • from your favorite albums (requires you to log in).

And as always, if you have any trouble with one of my app or one of my repo on github, please let me know.

Android app on Google Play Fork me on GitHub

Taming the LogCat (part 3)

Written by Xavier Gouchet - 31 january 2014 - no comments

Those who have used the adb tool might have stumbled upon the following message :

$ adb logcat
     - waiting for device -
     error: more than one device and emulator

In such case, you need to find, then specify the device's serial like this :

$ adb devices -l
    List of devices attached 
    XXX900AKC2             device usb:3-1.3 product:falcon model:XT1032 device:falcon_umts
    XXXBDAD913017009       device usb:1-1   product:yakju  model:Nexus  device:maguro

$ adb logcat -s XXXBDAD913017009

Here I used the logcat command but it's the same thing when you want to install an apk or pull a file from a device.

I've just discovered that if you don't specify a serial, adb will look for an environment variable named ANDROID_SERIAL to know which device to use. If you're often using several devices in USB, you can just add the following aliases to your .bashrc file.

alias adb-use-galaxy-nexus='export ANDROID_SERIAL=XXXBDAD913017009'
alias adb-use-moto-g='export ANDROID_SERIAL=XXX900AKC2'
alias reset-android-serial='unset ANDROID_SERIAL'

When using the adb logcat command, you can also set in the ANDROID_LOG_TAGS environment variable a list of tag/severity filter, like in the following example.

# suppresses all log messages except those with the tag "ActivityManager", at priority "Info" or above, and all log messages with tag "MyApp", with priority "Debug" or above
export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S"

These tips are fully compatible with the PidCat tool I talked about earlier.

A developer's tool : Grid Wichterle

Written by Xavier Gouchet - 12 november 2013 - no comments

Many apps exists to enforce good UI design in Android Apps, some embedded in the developper settings screen. This app is a small simple app that you can add to your toolbox.

Grid Wichterle

As you can see on the screenshot above, the app draws a grid above your Android UI, to let you see if your views are aligned following the design guidelines.

The project is Open Sourced on Github and can be downloaded on the Google Play Store