Wednesday, August 17, 2011

Movies App - Upgrade

I have worked on some enhancements and performance upgrades for the previously posted movies app.

Performance Improvements


Problem

  •  While moving through the list on phone or emulator, the images are loaded from internet directly. Because of this if it is on WIFI, the list moves faster and if it is on 3G, the list moves slower

Solution
  • Pictures must be loaded using a cache/multi-threaded synchronous model
  • Initially the file is downloaded and retrieved using a synchronized process
  • This image is cached using hash maps
  • Requires permission type - WRITE_EXTERNAL_STORAGE

Initial Screen


While scrolling a temporary image is loaded first
and then the original image from cache


Enhancements


- Check on WIFI status and issue a caution note
  •  The WIFI status is retrieved by invoking a system service which returns the network info
  •  Requires permission type  - ACCESS_NETWORK_STATE

When there is no WIFI,
 the warning is displayed


When the WIFI is enabled.
the warning is not displayed

- Show a progress dialog while the movies list is loaded
  •   Initiate the progress dialog
  •   Moved the retrieval of movies list and  movie adapter retrieval in an async task
  •   Destroy the progress dialog after the adapter object is retrieved
  •   set this adapter to the ListActivity


- Filter text box to filter/search the movies based on contains
  •   Placed a text box and list view in the main layout
  •   Associated the main layout to the ListActivity
  •   Implemented text box functions
  •   Invoke adapters getFilter and provide the CharSequence entered
  •   Override the getFilter,getCount and getPosition methods in the adapter
  •   write the functionality to filter the movies which contains the CharSequence (StartsWith can be implmented if needed)
  •   In getCount method check if filtered list has any items and return the size of this list

Results when Filter/Search term is "Anr"


Results when Filter/Search term is "Ntr"

Lessons learnt


  • While trying to cache the list of movies objects. The Bitmap does not get saved to the object and throws notserialized exception
  • The position inside the getView depends on the getCount from the list




Thursday, August 11, 2011

My first Android app - Telugu Movies

Introduction

I have decided to write an Android app after a long time and actually made a basic simple app. This app is called Telugu Movies app where it displays list of full length movies. This app displays a welcome/caution screen and then it redirects to list of movies where each item in the list is displayed with a thumbnail retrieved instantly from YouTube and some text like Movie name. When a movie is selected it plays the movie using the Android native YouTube player.

I have divided development of this app into parts

1) To display list of movies with welcome/caution screen
     1.A) To do same task above using JQuery mobile and Android WebViews 
2) To filter these movies using some searchbox/filter widget
3) To add fast scrolling
4) To add icons and tidying the app to look nice

Technologies used so far
  1. Java
  2. XQuery
  3. Android API (List Activity, Array Adapter, Layout Inflater, etc)

Application Flow



Screenshots

Welcome/Caution Screen Movies List Screen 1 Movies List Screen 2

     
Lessons Learnt

  1. Use Layout Inflater to actually generate a smooth scroll and good performance while generating the items in the list
  2. Tried to use Saxon Java API to render the XML and use XPath to retrieve values from the XML but Dalvik VM does not have support for some third party API's
  3. While working with filters, the actual Filter widget only works with keyboard based Android phones. For soft keyboards one needs to have a text box on the top of the list for the user to enter text to filter.

References

http://www.vogella.de/articles/AndroidListView/article.html#listsactivity_layout

http://saxon.sourceforge.net/saxon7.0/api-guide.html

http://developer.android.com/reference/android/widget/Adapter.html



Wednesday, July 6, 2011

Markana Android Tutorials

These are the android tutorials which are very useful in learning the application from scratch.

Title: Class 1, Part 1: Android Bootcamp - A 9,000 foot overview

Description: Get started on developing Android applications with Eclipse-based development tools in this 70-minute overview of the Android platform. In this first part of Class 1, Marko will take you through the Android software stack, the Dalvik VM, and setting up the Android SDK with the Eclipse environment.


Title: Class 1, Part 2: Android Bootcamp - Helloworld (anatomy of an Android app)

Description: In this 50 minute tutorial Marko will dissect an Android application in-order to provide you with a detailed look at all of the pieces that make up the Android APK. By the end of this tutorial, you will be familiar with all of the important components in the Android APK, as well as becoming more familiar with developing for Android in an Eclipse-based environment.


Title: Class 1, Part 3: Android Bootcamp - Main Building Blocks

Description: In this 70-minute tutorial Marko will demonstate the main building blocks for Android application development by showing you the processes behind a real world Android app.


Title: Class 1, Part 4: Android Bootcamp - Android UI

Description: In this 2-hour tutorial Marko will build an Android app from scratch in-order to illustrate some of the key concepts for Android UI development. By the end of this tutorial you should have a solid foundation for beginning to work with the Android UI, as well as some best practices for UI development.


Title: Class 2, Part 1: Android Bootcamp - Spicing up the Android UI

Description: In this 50-minute tutorial, Marko will pick up where he left off with in the last session, and show you how to spice up the Android UI by adding graphics, themes and colors. After watching this tutorial, you should have a solid feel for how to enhance the Android UI and how to use Eclipse to make it happen.


Title: Class 2, Part 2: Android Bootcamp - Drawables

Description: This 60-minute tutorial will focus on Android drawables and how you can use styles and the draw9patch tool to ensure they look great and scale properly across devices.


Title: Class 2, Part 3: Android Bootcamp - Traceview

Description: In this 40-minute tutorial, Marko will show you how you can use the Android SDK tool Traceview to analyze data and debug issues in your Android application. By the end of this tutorial, you'll know how to generate log files containing information you want to analyze, and then use Traceview view that information graphically.


Title: Class 2, Part 4: Android Bootcamp - AsyncTask, Preferences, and Options Menu

Description: In this tutorial Marko will begin with an explanation of threading in Android, and how you can use AsyncTask to enable proper use of the UI thread. Marko will also cover how the Android file system is organized as well as how you can use intents and the options menu to jump from one activity to another.


Title: Class 3, Part 1: Android Bootcamp - Application Object

Description: In this Android tutorial, Marko will show you how to create your own implementation of the Application object, which you can use to make common features accessible to most parts of your Android app.


Title: Class 3, Part 2: Android Bootcamp - Android Services

Description: In this Android services tutorial, Marko will show you how to create an Android service that will pull data from from a twitter-like web app and then store that data locally on the device, making it available to your Android app even when it is offline. After watching this tutorial, you will know how to: Create the Java class representing your service, register the service in the Android manifest file (androidManifest.xml), and start the service.


Title: Class 3, Part 3: Android Bootcamp - Databases

Description: In this tutorial, Marko will show you how to set-up a SQLite database to store local data for your Android application. The database service will run in the background and periodically update the database to ensure that the data needed for your Android app is relatively fresh.


Title: Class 4, Part 1: Android Bootcamp - statusData

Description: In the previous tutorial, Class 3, Part 3, you learned how to create a local database for your Android app. Now, Marko will show you how to create the service (UpdaterService) that pulls data from the cloud and then inserts it into your local database.


Title: Class 4, Part 2: Android Bootcamp - TimelineActivity

Description: In this tutorial, you're going to learn how to create a new activity called TimelineActivity that will display all the statuses from your friends. It pulls the data from the database and displays it on the screen. Initially, we do not have a lot of data in the database, but as we keep on using the application, the amount of statuses we have may explode. Our application needs to account for that.


Title: Class 4, Part 3: Android Bootcamp - Lists and Adapters

Description: In this tutorial, you are going to learn how to use Lists and Adapters. Lists and Adapters form a very powerful component in Android that lets your Android Application's tiny UI to connect to potentially very large datasets in an efficient and scalable manner.


Title: Class 5, Part 1: Android Bootcamp - BaseActivity

Description: Now, that you've created the Timeline activity, you're going to give it an options menu that will allow users to toggle the service on/off. Instead of copying and pasting code that we've already written, we're going to again refactor the code


Title: Class 5, Part 2: Android Bootcamp - Publishing to Android Market

Description: In this video, Marko is going to show you what you need to know to get your Android app ready and published in the Android Market.


Title: Class 5, Part 3: Android Bootcamp - Broadcast Receivers

Description: In this tutorial, you are going to learn how to use BroadcastReceivers to notify an application of an action to which it is subscribed. Marko will also cover: Adding Custom Permissions, Declaring Permissions in the Manifest File, Updating the Services to Enforce Permissions.


Title: Class 5, Part 4: Android Bootcamp - Location Services

Description: In this tutorial, you are going to learn how to use BroadcastReceivers to notify an application of an action to which it is subscribed. Marko will also cover: Adding Custom Permissions, Declaring Permissions in the Manifest File, Updating the Services to Enforce Permissions.