Category: Android

  • Handling the multi-touch in a view

    In this post you find a full example about how to extend a view to draw, in this case, a circle where you touch the screen implement a listener on a view to handle the multi-touch

  • Displaying notifications and progress bar from an instance of AsyncTask

    The AsyncTask class is used to perform background tasks and it might be useful to show notifications and progress bars to alert the user. In this post I write an example where I create two AsyncTask instances showing a startup notification, a progress bar and a notification of completed task

  • How to display an icon in the preferences

    In the Android preferences you can put different types of controls: check box, edit box, list,…, but none of these displays an icon (see Settings). Usually a preference consists of two lines, the title and the summary, and after you have clicked you get a dialog box where you can select the chosen item, as…

  • How to implement Up Navigation

    In this example you can see how to implement the Up Navigation, i.e. the option to go back to a previous activity using the button in the upper left of the action bar. The previous activity can be a fixed activity or an activity determined at runtime.

  • Replacing a Fragment in a Tab Layout with an ActionBar

    In the post Tab Layout in Android with ActionBar and Fragment the fragments can’t be replaced later, in this post I write the changes in order to replace the first fragment of the first tab with a third fragment using a button at runtime.

  • The services in Android

    A service is a task running in the background to perform actions without a user interface and they are used to perform long running operations with a significant use of resources by avoiding delays in the user experience. The services belong to one or both of the following categories: started: the service is launched using…

  • Passing an object from an Activity to another

    The method startActivity(Intent intent) of the class Activity allows you to call a second activity specified using the argument Intent. You can associate primitive data or primitive data array to the argument Intent and then the second Activity can access them, you can also pass objects of type String using methods of the class Bundle…

  • Javadoc in Eclipse and Android

    In Eclipse launching javadoc from menu (Project -> generate javadoc…) if you get the errors: error: package android… does not exist error: cannot find symbol

  • Getting the Context inside a Fragment

    It is very easy to get the Context inside an Activity: with the getApplicationContext() method using only “this” because the Activity class extends the Context class But you can’t use any of these two methods inside a Fragment and you have to replace them respectively with: getActivity().getApplicationContext() getActivity() I often do this replacement when I…

  • Script for creating Android Icons

    Just another tool to create Android icons, such as gimp-android-xdpi. You can find at Script for creating Android Icons or at GIMP script for creating Android icons at once.