Latest Android devices, like Nexus 4, Nexus 7, Galaxy Nexus, ... are using 2 different USB connexion modes : PTP and MTP.
With PTP mode, the phone is seen as a digital camera. This is working Out Of The Box under Ubuntu 12.04 LTS. But, you can only access DCIM directory of your device.
With MTP mode, the phone is seen as a multimedia device where you can access the complete exported filesystem. But it doesn't work Out Of The Box under Ubuntu 12.04 LTS. It needs some setup and configuration to work.
This guide explains how to easily configure your Ubuntu computer to directly access your Android devices filesystem in MTP mode as soon as you plug it to a USB port.
It is based on a previous guide done for Nexus 7, but has been modified to become fully automatic, providing a script which is a one click solution to configure virtually any MTP device.
Thanks to this script, your Android devices will be properly declared to automatically mount when plugged & unmount when unplugged. You'll be able to handle multiple devices at the same time on your ubuntu computer.
This guide has been completly rewritten to use mtp-detect. It has been tested with a Google Nexus 4 and a Google Nexus 7, but it should work with any other MTP device (Android phone or tablet, MP4 player, ...). It has been done under Ubuntu 12.04 LTS Amd64 but it should work or be easily adapted on many Linux flavours.
Main script used in this article is available from Github mtp-automount project.