Monday, October 29, 2012

Android Tips 1: Choosing Minimum SDK & Target SDK Versions

According to the Android Platform Usage Statistics by Google (which is continuously being updated every 14 days), Gingerbread, ICS and Froyo are being used by 57.5%, 20.9% and 14% people respectively. The APIs have significantly changed since Froyo. So, if we choose Froyo as the minimum SDK version for Android apps, we can serve over 95% of people. So, we recommend choosing Froyo (API Level 8) as the minimum SDK version.

As for the target SDK version, i.e., the version that should be used to compile the application, always using the latest SDK version is recommended. Thus we can take advantage of various features introduced in the later APIs (for example, Action Bars) while keeping backward compatibility down to Froyo. As of this writing, the latest SDK version is 4.1 - Jelly Beans (API Level 16).

However, after setting the target SDK version to the latest SDK, be careful with choosing APIs. Using an API of Level 11 would compile the application fine with target SDK Level set to 16, but running the application on a Gingerbread device would cause it to crash. For example, a commonly-used ListAdapter class is ArrayAdapter. In that class, to add elements to the adapter all at once, the addAll(List) method has been introduced in API Level 11. So, you cannot use that method while having the minimum SDK version set to API Level 8 (Froyo). The documentation of each method includes the information since which API Level the method has been introduced. So, you need to keep an eye on that so as to use a method compatible with the API Level set as the minimum SDK version. The same is true for constants as well.

Finally, to set the minimum and target SDK versions, open up AndroidManifest.xml and put the following line within the <manifest></manifest> tags (and before the <application> tag):

<uses-sdk android:minSdkVersion="8" 
          android:targetSdkVersion="16" />

Saturday, September 15, 2012

CV Writing Guidelines

A CV is sort of advertising yourself. In an engineering job or teaching job the employer is not interested at all in how nice looking you are or where is your home district etc.
So, it is better not to give your photograph or biographical information (Parent's name, home district, national ID no, passport no. etc. etc.) in your CV.

You can divide your CV into a number of sections:

1. Contact Information

2. Educational Qualification
List up your degrees with results [There is no need for SSC and HSC result], In case of BSc you can separately give your CGPA in CS subjects

3. Technical Skills
Group your technical skills into several categories. e.g.

Programming Language: C/C++, Java, C#.Net, Verilog HDL
Server Side Scripting: ASP.Net, PHP
SDK and Framework: Jakarta Struts, Android SDK
Compiler Tools: Lex, Yacc
Simulator: PSpice, NachOS, Packet Tracer
.
.
.
and so on.

4. Research Interest / Experience
5. Undergraduate Thesis
6. List of Publication [if any, if you've submitted any paper to any conference / journal you may also refer it]
7. Major Hardware and Software Projects
You may order this list by putting the best project you think you have done at top and then in decreasing order of importance to you.
Don't write just like "4 bit micro computer". Put a little bit of description like. "Design and implementation of a 4 bit micro computer supporting
18 instructions and 2 stage pipe lining". Or "An automated reservation system for airlines with X, Y, Z features. MySQL was used as RDMS, PHP was used as server side scripting language and HTML/CSS/Javascript/AJAX was used on build the client end interface ".If there is any webpage for your project you may also give the link. There is no need to give project partner / supervisor's name.
8. Awards and Honors
9. Extra curricular Activities. [ you may put up your achievements in programming contests, project shows, software contests, olympiads etc. etc.]
10. A list of references
This is usually a list of contacts (preferably 2, at most 3) who can say something about you if your employer contacts them. In our country the employers
usually don't contact the referees. But in case you are applying for any international job your employer may contact the referees. Normally people put the name
of their advisers / thesis supervisors as referee. You can put any professional / academic contact who knows you well. Or you may just put like "Available upon
request"

Now don't make your CV too long or too short. The optimal size is around 2 pages. Keep one thing in mind, the recruiter who goes through the CVs have to
handle a lot of them. When he has a CV he gives the most amount of attention on the first page, the attention reduces in second page, and s/he might not
even look at the third page.

If you are applying for a teaching position in an university your research experience, list of publication, thesis are given more importance. So you may order the sections like 1,2,4,5,6,3,7,8,9,10 so that these things come in the first page or at most in the second one.

If you are applying for an engineering job then your technical skills, past project experience are given more importance. So in this case your ordering may look like
1,2,3,7,4,5,6,8,9,10 so that these things get more highlight.

These are not any hard and fast rule. They are just guidelines. Give some time on your CV. You'll come up with even better ideas. You can also search the internet for good CV examples. There are lots of them. There are even some good CV templates in the internet in LaTeX. The document produced with LaTeX looks very crisp and nice. So you can give it a try to make a one with LaTeX.

In future you'll be required to submit a CV in numerous occasions. So give some time behind it.

Essential Android Concepts

To work with Android application development, we need to know a few basic things. Here, a brief discussion on those concepts will be provided as well as links to presentations discussing those topics in details.

Activities

More-or-less, anything we see on the screen of an android device and interact with it may be called an activity. For example, in the following figure, each of the screens is an activity.


Intents

An intent is simply an action optionally bundled with data on which the action is to be performed. As an example, consider the figure above. When a user taps on a list item, the details of the list item is shown. However, there are many list items and clicking any of those will result in the same details view, but with different data, depending on the tapped list item. So, when starting the details activity, we need to know which list item has been clicked by the user. This data along with the activity name that we want to start, is bundled into an intent and then a new activity creation request is placed.

Intents are not merely for starting activities. To know other functionalities of intents, see the presentation Android Insights - 1: Intents.

Services

Whereas an activity is any operation that is visible to the user, a service is any operation that is hidden from the user, run in the background. For example, you may set an alarm to go off at a certain time. This service is referred to as the Alarm Service. A service may start an activity, however. For example, the alarm service may present a view to the user so that he may stop or snooze the alarm.

Usually, services are background services. The user doesn't need to be aware of such a service being run. Whenever the android system needs memory, it may kill the service while it's running. However, there may be services that the user is actively aware of and he won't be happy if the service is killed while running. For example, a user may start playing a song and move from the player to another application and work therein. The song will continue to play in the background as a service. However, killing the background song when in short of memory will displease the user. In this case, the developer of the background service needs to notify the android system that it shouldn't kill such a service. Identifying the service as foreground rather than background is the trick for it. Details about setting a service as foreground as well as in-depth discussion on services in general can be found in the presentation Android Insights - 2: Services.

Content Providers

Suppose you're fed up with the built-in Contacts application and plan on developing a rock-and-roll Contacts application. You'll need to get access to the contacts in the user's phone. But how would you request for the stored contact details and more importantly, to whom in the android system? Content Providers solve the problem. A content provider provides content (which can be anything - any information) through some well-defined interfaces. It's implemented in such a way so that users of the content provider can code as if they were accessing records from a database. Again, you can also use a content provider to provide access to your application's internal data through interfaces defined by you.

To know more about content providers, follow Android Insights - 3: Content Providers.

Wednesday, September 5, 2012

Generics in Java

A problem - developing a general-purpose list of elements

Suppose we're writing an application where we need a general-purpose 'container' that would contain many 'elements'. To be more technical, this 'container' can be called a 'list', and its 'elements' can be virtually anything - integer, float, string or any type of object.

So how should we write a class for it? (Ignore for the moment that we already have a built-in List interface and its various implementations.) Let's try writing such a class:
public class List {
    //here in an instance variable (perhaps an array)
    //we will store the elements
    public void add(??? element) {
        //add the element to the store
    }

    public ??? getElementAt(int index) {
        //return the element at index
    }

    //some more methods as needed...
}
Concentrate on the highlighted portions in the code above. Yes, the challenge is to provide a single data-type which can be used for anything - integer, strings, objects and so on.

Initial solution - use the Object type

Object class is the parent of all classes. So, using it will solve the problem of a generic data-type. Of course you won't be able to use the primitive data types (int, float, double etc.), rather you'll use their corresponding wrapper classes (Integer, Float, Double etc.).

Problem with using Object type

However, using the Object type would cause your list to include elements of various types. For example, you could have a list with 2 integers, a float and 3 strings. This may cause problems. As an illustration of such a problem, consider the fact that you might like your list to be sorted in some order (actually it's a common requirement for a list of elements). If all the elements in the list were of a single type only, then there won't have been any problems. But as the list contains both integer and string values, how would you sort them??

Meet Generics

Generics came to solve this problem. To make sure that you use a list for elements with the same data-type, a special syntax is used:
public class List<E> {
    //here in an instance variable (perhaps an array)
    //we will store the elements
    public void add(E element) {
        //add the element to the store
    }

    public E getElementAt(int index) {
        //return the element at index
    }

    //some more methods as needed...
}
The E in the above refers to a generic element type. Whenever you instantiate the class, you will replace the E with whatever type you want all your list elements to be of. For example, below we instantiate the list class to include only integer elements:
List<Integer> integerList = new List<Integer>();
integerList.add(5);
int element = integerList.getElementAt(0);
Similarly, we can use the exact same class for storing strings:
List<String> stringList = new List<String>();
stringList.add("Hello World");
String element = stringList.getElementAt(0);
So this is all about generics. Simple, isn't it?

In the next Java blog post, we'll see some examples of generics through using the Java Collections Framework.

Monday, September 3, 2012

Roadmap for learning Android

Similar to the "Roadmap for Learning Enterprise Java", we'll be posting tutorials, tips and tricks on various tools and technologies used in developing professional Android applications. Following is a list with short descriptions on what topics we will be covering in detail. Note that most of the topics below coincides with the topics in "Roadmap for Learning Enterprise Java". So, those topics will cover for both Java Enterprise and Android. (If you haven't already gone through the above blog post, please do it now.)
  1. Essential Android Concepts
    • Activities
    • Intents
    • Services

  2. Development Tools & Techniques (Part 1) - IDE, Debugging

  3. Introduction to Roboguice
    In easy terms, Roboguice will remove lots of boilerplate code from your app, causing the code to be more concise, organized and easy-to-read. It'd speed up your development time and minimize development efforts as well.

  4. Fragments: Developing Universal Applications for Both Phones & Tablets
    Tablets have significantly more screen real estate than cell phones. We'll show you how to write an application so that it will show up in a cell phone as usual, but utilize the extra screen space in a tablet and enhance the user experience with the app. If you're curious enough, take a look at what the Android Guide says about it.

  5. Database Design & SQL

  6. Coding Best Practices and Writing Good Code
     
  7. Development Tools & Techniques (Part 2) - Git
     
  8. Black-Box Testing with Robotium
    Black-Box Testing is a testing technique where the functionality of an application is tested irrespect of knowing how that functionality has been implemented in code. After an application has been developed, whenever a new feature is added to it, all the previous features need to be tested along with it, too (so as to verify that no previous feature has broken due to the side effect of the new code). Testing it manually each time a feature is added is laborious. Robotium provides a solution to automate the black-box testing process and thereby eases our life with developing android applications.
That's pretty much all. So, stay with us!