New tutorials

Welcome to our Tutorials section! We are working hard to bring you high quality and interesting tutorials. Also check out the tutorials forum if you have any problems or want to make a request. Also, if the text in the code samples is too small, click here for an explanation.

  • How to add divider items to ListView

    Today I'm going to show an easy way to add divider items to your ListView.
    First off, you need your own ListView Adapter which extends SimpleAdapter. If you don't know how to create a new class for your own SimpleAdapter, please go and visit: http://developer.android....

  • Running code on phone boot

    Some applications, for example a mail client, needs to run in the background all the time. You may want to run code right after the device booted.


    The device is booting

    In the Android system BroadcastReaceivers are just for such mechanism, they can listen for defined intents with given parameters, and run code when they receive one, even when your application is...

  • Gzipping files on the fly part 1.

    Today we wanted to test ways, to optimize the download of files to android phones.
    The first way we tried, is the most obvious method of using a little less of everything (bandwith, battery, cpu, backlight, time? etc), compression.

    Image source.

    But what about speed? Is it worth to sacrifice the app's speed for using less bandwith? How much slower...

  • Simple connection example part II - TCP communication

    Last time I wrote about UDP connection. I got some comments about the problem, that UDP packets are not guaranteed to be delivered.
    This time I’m going to show you the safer option, the TCP connection.
    TCP is probably the most commonly used protocol, simply because it is used for so many applications such as HTTP, POP, SMTP, etc. TCP is a protocol which guarantees that the receiver will receive exactly what the sender sent - there will be no errors, it will be in...
  • How to run background jobs using threads

    Previously I wrote about, that slow operations must be runned in threads. Now I would like to present some example code, how to use threads in Android.

    Under the android system an user interface element can only be accessed from the thread that created it (the main UI thread). Thats where handlers and messages come in.

    The user interface defines a handler like below:

      ...

  • Simple UDP communication example

    Today I’m going to show you how to create a really easy and simple UDP message sender and receiver.


    Udp communication time diagram.

    The User Datagram Protocol (UDP) is one of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer applications can send messages, in this case referred to as datagrams, to other...

  • Maintaining global Application state

    As a possible solutions mentioned in previous article Leaving an Android application the Application object can come handy. If you want to store data, global variables that needs to be accessed from everywhere in the application, from multiple Activities, in other words is you want to maintain a global "state" of the whole application the Application object can help.

    For this we must make a class which...

  • How to create a custom titlebar

    If you got sick and tired of the default style/behavior of the title bar in your apps, or just need something different, than here is a little snippet for You.

  • Wallpaper tutorial - Part 2

    This article was requested by some of our community members. It is based on the Android Gallery, ImageView Example tutorial by Sasikumar (Part 1 is here). I extended his example with a new function. If you long click on the big image, an alert dialog show up and ask “Do you want to use this image as a wallpaper?". If...

  • Speeding up android applications

    First of all, define what do we mean under "speed": in one hand its the time that the code needs to execute, on the other hand its the time the user needs to wait for the user interface. The two things can greatly differ, of course you must optimize the code performance, but the most important is what the user sees from it. Don't make the user wait, unless its necessary.

    Do not pull back the ui thread
    The very basic principle is to never run slow operations on the user...