Thursday, October 11, 2012

Custom ListView with TextViews and ImageView

Tutorial 1 - Creating a custom ListView with unique style and elements

In this tutorial, we're going to go over the basics of Android's ListView container and see how we can customize it so it looks a little less...well..plain. The default layout that ships with the sdk is fine. It's basically just a listed view containing text fields with a black background. You can find out more about creating a standard ListView here See photo below.


 However, if you want to customize your ListView so it looks a little different and contains dynamic data..keep reading. I used this design in an app I wrote called EZ Pics Photo album, basically an easier way to sort/organize your photos on your Android device. We will build this ListView from scratch, see the end result below. 

 Only one caveat; Disregard the ActionBar at the top of this layout, as we will not be building this design pattern in this tutorial. For that, I used the GreenDroid open source library which you can find on GitHub.
Also, There are 2 drawables that I made for the purpose of this project. The photos/camera icon on the left and the blue arrow on the right. I haven't included these files in this tutorial, so feel free to use your own drawables.

Now onto our custom ListView. Let's break down what components make up this viewgroup before we get to writing any code.

1) Notice that each element in the ListView contains 4 pieces of data. ImageView, ImageView, TextView, TextView

2) Notice that there is a space between each view in the list. This space is called a divider.

3) Notice that this ListView contains dynamic data, ie; number of photos is different in each element, as well as the TextView title. The ImageViews on the left and right sides remain the same.

4) The ListView rows have a sort of grey-gradient style to them rather than a flat, solid color that the standard one provides.

Let's set up our files. Create  new project in Eclipse. You will need these 2 files in your res/layout folder.

main.xml
listview_row.xml

In your drawable folder, you will need to create these files

 list_divider.xml
list_item_normal.xml
list_item_pressed.xml
list_item_selected.xml
listview_background.xml
selector.xml
shape_background_grey.xml 

In your res/values folder, create these files.

 styles.xml


These are basically all the resource files you will need. We will break down each in order to fully understand how we couple XML with Java in this project to achieve the desired results.

Ok, so first our main.xml. This file should look like this.

Main.xml


 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     
 4     android:layout_width="fill_parent"
 5     android:layout_height="fill_parent"
 6     android:background="#708090"
 7     android:orientation="vertical" >
 8 
 9     <ListView
10         android:id="@+id/lvAlbumList"
11         android:layout_width="fill_parent"
12         android:layout_height="wrap_content"
13         android:cacheColorHint="#00000000"
14         android:clickable="false"
15         android:divider="@drawable/list_divider"
16         android:dividerHeight="3dp"
17         android:listSelector="@drawable/selector"
18         android:drawSelectorOnTop="false"
19        
20         android:padding="2dp" >
21     </ListView>
22     
23     
24      
25 
26 </LinearLayout>
 
 

listview_row.xml 

 Our listview_row.xml will represent each individual row in our list. You'll notice that unlike the default ListView tutorial, we are creating a separate xml file to represent an individual row. Why? This is because we will later create a custom ListAdapter that will be responsible for not only inflating each view in the list, but binding the data to it as well. We want to have total control over how each element in our list is drawn, and also because we will be extending Activity instead of ListActivity.

We use a RelativeLayout as our root view because it gives us more control over how we can position our child views. We will assign a custom background to this layout in a bit. Remember that we have 4 children views(2 TextViews and 2 ImageViews). Play around with the gravity, padding, and position of each of your ImageViews and TextViews in order to get your desired result. The code is below


 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:id="@+id/relativeLayout1"
 4     android:layout_width="fill_parent"
 5     android:layout_height="fill_parent"
 6     android:background="@drawable/listview_background"
 7     android:padding="5dip" >
 8 
 9     <ImageView
10         android:id="@+id/imgViewLogo"
11         android:layout_width="50dip"
12         android:layout_height="50dip"
13         android:layout_alignParentLeft="true"
14         android:scaleType="fitXY"
15         android:src="@drawable/imgview_drawable" >
16     </ImageView>
17 
18     <TextView
19         android:id="@+id/txtViewTitle"
20         android:layout_width="wrap_content"
21         android:layout_height="wrap_content"
22         android:layout_marginLeft="2dip"
23         android:layout_toRightOf="@+id/imgViewLogo"
24         android:text="TextView"
25         android:textAppearance="?android:attr/textAppearanceLarge"
26         android:textColor="#43c6db"
27         android:textStyle="bold" >
28     </TextView>
29 
30     <TextView
31         android:id="@+id/txtViewDescription"
32         android:layout_width="wrap_content"
33         android:layout_height="wrap_content"
34         android:layout_below="@+id/txtViewTitle"
35         android:layout_marginLeft="2dip"
36         android:layout_toRightOf="@+id/imgViewLogo"
37         android:text="TextView"
38         android:textColor="#000000"
39         android:textStyle="bold" >
40     </TextView>
41 
42     <ImageView
43         android:id="@+id/imgViewArrow"
44         android:layout_width="35dip"
45         android:layout_height="35dip"
46         android:layout_alignParentRight="true"
47         android:layout_marginTop="3dp"
48         android:scaleType="fitXY"
49         android:src="@drawable/custom_arrow" >
50     </ImageView>
51 
52 </RelativeLayout>

Next, create a res/drawable folder if you don't already have one. This is where we'll define a few more xml files that will make our ListView even more powerful and customized.

listview_background.xml

 This is where we define our background of our list view. This xml file defines a shape object and basically specifies that it will be colored using a gradient. the start, center and end colors. Feel free to play around with this color values as well if you want your background to be a different color. Or maybe you don't want a gradient at all. That's fine. Play around with different values in this file in order to get your list items to look just how you want. 

The <corners> element is what defines the rounded edges of our list items. Remove this if you don't want them to be rounded. I thought it looked cool so that's why I included it in my project.

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <shape xmlns:android="http://schemas.android.com/apk/res/android" 
 3     android:shape="rectangle">
 4 
 5     <gradient
 6         android:centerColor="#E6E6E6"
 7         android:endColor="#CCCCCC"
 8         android:startColor="#FFFFFF" android:angle="270"/>
 9     <!--
10          <gradient android:startColor="#FF66CFE6" android:centerColor="#FF207FB9" 
11         android:endColor="#FF0060B8" android:angle="270"/>
12     -->
13 
14     <stroke
15         android:width="2dp"
16         android:color="#43c6db" />
17 
18     <padding
19         android:bottom="3dp"
20         android:left="3dp"
21         android:right="3dp"
22         android:top="3dp" />
23 
24     <corners android:radius="7dp" />
25 
26 </shape>
 
 

selector.xml 

 Now that  we've defined our listview row and it's background style. Let's define a custom selector for when each element in our list is touched.


<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle">
 
      <gradient
         android:centerColor="#adff2f"
          android:endColor="#adff2f"
          android:startColor="#adff2f" android:angle="270"/>
      <!--
          <gradient android:startColor="#FF66CFE6" android:centerColor="#FF207FB9" 
         android:endColor="#FF0060B8" android:angle="270"/>
    -->

    <stroke         android:width="2dp"
         android:color="#43c6db" />
 
     <padding
         android:bottom="3dp"
         android:left="3dp"
        android:right="3dp"
        android:top="3dp" />
 
     <corners android:radius="7dp" />
 
 </shape>
 
 

list_divider.xml

 
 
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
 3 
 4     <item>
 5         <shape>
 6             <gradient
 7                 android:angle="90"
 8                 android:endColor="#708090"
 9                 android:height="2dp"
10                 android:startColor="#708090" />
11             
12             
13             <corners android:radius="7dp" />
14         </shape>
15     </item>
16 
17 </layer-list>
 
 This is to define our divider between our list elements. The android:height attribute tells us that our space between the list elements will be 2 density independent pixels high. If you don't want the items in your list to have a divider, simply skip creating this file and remove the android:divider tag from the main.xml file that we created above.

If were to run our app now, we should get something like the below result


Ok, so you just set up your project and copied all that code. You define your listview, it's background and even 
 a custom selector. You launched the MainActivity, where's the list?

The ListView contains no elements, you have an empty list. So nothing shows up because you 
didn't feed your list any views to be drawn. We need to do a few more things in order to get our listview up and running.

Let's extract our custom ListView from it's parent in main.xml, inflate it..and fill it with some data.
 This is known as data binding. We'll have to create a custom ListAdapter that will do the binding for us each time our list receives new data.

This is what the MainActivity class should look like as of now


 1 package com.aquarius.customlistviewproject;
 2 
 3 import android.app.Activity;
 4 import android.os.Bundle;
 5 
 6 import android.widget.ListView;
 7 
 8 public class MainActivity extends Activity {
 9 
10  ListView albumList;
11 
12  @Override
13  public void onCreate(Bundle savedInstanceState) {
14   super.onCreate(savedInstanceState);
15   setContentView(R.layout.main);
16 
17   albumList = (ListView) findViewById(R.id.lvAlbumList);
18  }
19 
20 }
 
We've created a ListView object and then we inflated it using findViewById. 
 
Next, create another class named ListViewCustomAdapter. The code for that class
looks like this
 
1 package com.jbsoft.TravelAlbums;
 2 
 3 import java.util.ArrayList;
 4 
 5 
 6 
 7 import android.app.Activity;
 8 import android.content.Context;
 9 import android.view.LayoutInflater;
10 import android.view.View;
11 import android.view.ViewGroup;
12 import android.widget.BaseAdapter;
13 import android.widget.ImageView;
14 import android.widget.TextView;
15 
16 
17 public class ListViewCustomAdapter extends BaseAdapter {
18 
19  public ArrayList<String> album_names;
20 
21  public ArrayList<String> photos;
22 
23  public Activity context;
24 
25  public LayoutInflater inflater;
26 
27  public ListViewCustomAdapter(Activity context,
28    ArrayList<String> album_names, ArrayList<String> photos) {
29   // TODO Auto-generated constructor stub
30   super();
31   this.context = context;
32   this.album_names = album_names;
33   this.photos = photos;
34 
35   this.inflater = (LayoutInflater) context
36     .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
37  }
38 
39  public int getCount() {
40   // TODO Auto-generated method stub
41   return album_names.size();
42  }
43 
44  public Object getItem(int position) {
45   // TODO Auto-generated method stub
46   return null;
47  }
48 
49  public long getItemId(int position) {
50   // TODO Auto-generated method stub
51   return 0;
52  }
53 
54  public class ViewHolder {
55   ImageView thumbnail;
56   TextView txtViewAlbum;
57   TextView txtViewPhotos;
58 
59  }
60 
61  public View getView(int position, View convertview, ViewGroup parent) {
62   // TODO Auto-generated method stub
63 
64   ViewHolder holder;
65   if (convertview == null) {
66    holder = new ViewHolder();
67    convertview = inflater.inflate(R.layout.listview_row, null);
68 
69    
70    holder.thumbnail = (ImageView) convertview
71      .findViewById(R.id.imgViewLogo);
72    holder.txtViewAlbum = (TextView) convertview
73      .findViewById(R.id.txtViewTitle);
74    holder.txtViewPhotos = (TextView) convertview
75      .findViewById(R.id.txtViewDescription);
76 
77    convertview.setTag(holder);
78   }
79 
80   else
81 
82    holder = (ViewHolder) convertview.getTag();
83 
84   holder.thumbnail.setImageResource(R.drawable.imgview_drawable);
85   holder.txtViewAlbum.setText(album_names.get(position));
86   holder.txtViewPhotos.setText(photos.get(position));
87 
88   return convertview;
89  }
90 
91 } 
 
The most important method in this class is the getView() method. It is responsible 
for basically giving us a converView that we can reuse to fill with our data. First, we check
if it's null..and if it is, we attach our default views to it. 
 
Then we use convertView.setTag(holder) to store our views. If the convertView is not
null, then we get the views that we stored with it and set our data to it.
 
The final code for the MainActivity class is below.


package com.aquarius.customlistviewproject;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {

 ListView albumList;
 
 ArrayList<String> albums;
 ArrayList<String> photos;
 
 CustomListViewAdapter adapter;

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
     
  albumList = (ListView) findViewById(R.id.lvAlbumList);
  
  
  fillData();
  
  //set up our adapter and attach it to the ListView
  adapter = new CustomListViewAdapter(this, albums, photos);
  albumList.setAdapter(adapter);
 }

 //Fill our arrays with some trivial String data
 private void fillData() {
  
  albums = new ArrayList<String>();
  photos = new ArrayList<String>();
  
  albums.add("Album1");
  albums.add("Album2");
  albums.add("Album3");
  albums.add("Album4");
  albums.add("Album5");
  albums.add("Album6");
  
  photos.add("1 photo");
  photos.add("2 photos");
  photos.add("3 photos");
  photos.add("4 photos");
  photos.add("5 photos");
  photos.add("6 photos");
  
  
 }
 
 
 

}
 
This should produce the result below. Note that we hardcoded some strings to fill the
ArrayLists, but that you can fill them however you like. Whether you want to get data off a server via XML, JSON or
whatever, just store the strings in an ArrayList and use it the same way. Also, play around 
with the XML files in order to get your listview style to look just how you desire.  
 


Wednesday, October 10, 2012

Teach Me 4 Kids!

I wrote this app because I wanted to create a simple game for small children that would teach them something. Recently I've been seeing alot of parents in malls and grocery stores with their kids, and the kids are using a smartphone or tablet. I figured it was just mom or dad wanting them to be occupied and not annoy, so why not give them your tablet or smartphone for a few minutes if they'll learn something?

 The idea was to set up a dashboard(actually a chalkboard) with different modules that they could engage in. I couldn't afford to hire a professional graphic designer to design some snazzy backgrounds and bitmaps for me, so that's where my photoshop skills came into play. I decided to give designing a try, and I don't think it turned out too bad. Ironically enough, drawing the little monkey guy for the title screen took me the longest, about an hour in CS5.

                                     
                                         

The current modules are as follows:


                    
                                        
ABC - I designed this to teach kids the letters of the Alphabet and how to pronounce each. They would also learn to pronounce common objects and animals that begin with each letter. I tried a few apps in the Playstore that aimed to accomplish a similar goal, but most of them used horrible text-to-speech software that sounded robotic and monotonous. I believed that a natural, enthusiastic, human voice was the only way to get and to keep a child's interest. I recruited the help of  a friend, I felt that she had a great voice for what I was trying to accomplish. We recorded the sounds of the letters and the sounds of the objects in my apartment on a laptop and a microphone. I edited them with Wav editor.

123 - The purpose of this module was to teach children how to count, in a fun and entertaining way. Most apps I'd tried just showed bunch of images of a particular object, and asked the child to touch on the number that represented that quantity. This approach almost expects the child to know how to count beforehand, and didn't consider teaching them. I drew up some fish .pngs in PhotoShop and I knew that I wanted them to be different colors because the child could also learn color recognition while learning how to count quantities. I'm still on the fence about this module, and I might even revamp it in future updates.



Recognizing Letters - In this module, I wanted to create fun way to teach kids how to recognize letters among each other. I figured, the alphabet module taught them the letters of the alphabet..now it's time for a quiz. The letters sort of cascade down the screen and a female voice asks you to touch a particular one. For every 5 correct selections you receive a different sticker on your screen.


There are two modules that are currently incomplete. Addition and Subtraction. I mentioned above that I want to incorporate a fun yet educational aspect to each module, but each has to be able to keep a child's attention span(almost impossible). I am still working on those last 2 modules currently, while refining some code for the others as well. I work on Teach Me whenever I'm not working. I also learned quite a few lessons while developing this one. Mostly that Murphy's Law always applies. The young lady that recorded the sounds for the ABC module was no longer available to continue doing the voice-overs for the rest, so I had to find a suitable alternative. I tried to avoid text-to-speech software as much as I could, until I found NeoSpeech Julie. It's honestly the most natural sounding TTS software I've ever encountered. Julie's voice is actually what is in the Counting and Letter Recognition modules, and most people can't believe that it's TTS software and not an actual person doing voice-overs. Check it out here if you're looking for good TTS software.

You can find Teach Me in the Playstore here

Suggested Reading

For anyone starting out in Android development, but has no Java experience whatsoever. Great book by Judy Bishop with tons and tons of examples that teach fundamental Java concepts in a easy to read way. I've read some controversial reviews about the book(some people out right hate it), but I had a decent experience with it and I found that is supplemented my Java programming course well.


Why is good design important?

Well designed Code Vs. Code That Just Works!

 One of the biggest lessons I've learned in my Android development experience to date
 is the battle between writing code that works, and writing code that is well designed. 

"What do you mean 'well designed'? I thought the purpose of writing code was to solve a problem, you know..get something to WORK"??

This logic couldn't be more flawed. It goes back to what our moms used to tell us when we were kids(at least mine did), "do it right the first time, and you'll never have to do it again". In a sense, this can be applied to software development. Whether you're a beginner, intermediate or seasoned vet..this understanding is vital to your success or failure in developing mobile applications, or any software for that matter.

Writing code that just works. It's not beautiful, but it gets the job done.

There's good and bad in everything, right? This approach is no different, and in some instances the q&d(quick and dirty) approach is just fine.

For example, when trying to find a quick workaround to a persistent problem in your code that you just can't crack. You're trying to figure out how to download some images off a server and display them in  GridView or Gallery that you've got set up in your Android project. It's a solo project anyways, no other programmers will ever see it, it will never be published, and you're just testing something anyways. Quick and dirty is fine here, because the purpose here IS to "just get it to work". So you hack away at some stuff, forgetting about Threads, Handlers, Background Tasks, Lazy Loading etc. You go ahead and write up some stuff that grabs your images off the server and displays 'em, all on the UI thread(more info on this later, it refers to the main thread in you Activity). Design patterns, maintainability and extensibility don't matter because you are just placing things in line to get them working anyways. You can refine later. Gotcha.

Now, when will this approach fail..and subsequently cause more harm than benefit? You ready for the truth? In EVERY other case.


Writing code with the future in mind. Maintainable, Extensible. Elegant.

I haven't been developing on Android for long, and before that I had never written any professional, published work. The first object oriented programming language I had experience with was C++ freshman year of highschool. I was on the robotics team and we wrote code in C++ that would communicate with a robot's cpu and get it to do different things. Before that, I had only messed around with Html and Javascript when I was around 12 or 13. So as you can see, Java(and Android) have been what I've spent most of my programming time with thus far.


 Believe me when I say that the lessons I learned during this process have been vital, and I'm glad I made some of the mistakes I did early because I learned to see things from both sides..and still learning!

One of the bad habits that I picked up early on, and admittedly still do this sometimes today; is what I like to call "raw programming". I don't know if that term or expression even exists in the computer software world, but I think it fits perfectly. It should. 

What I mean by "raw programming" is just what I mentioned above. Hacking away at some code, without any real direction or consideration for where this ship is going. The reality is that the ship is sinking, fast. You know the problem you're trying to solve, you have a vague idea of how to fix it. Add that with some half-assed inspiration and you're in for a bad time. You rush the work, racing to escape from the dreaded ANR dialog(Activity Not responding, aka "Force Close"). You write the code, screw the comments(No one else is gonna see this anyways, right?). You eventually get rid of the bug and all is well with the world.

You continue working, and after a few hours and a couple replays of your favorite Bob Marley album, you discover another bug. This time you haven't a clue of what happened, but you know that it's related to code you chopped up earlier(at least you think it is).

I like to call this phenomena "quick & dirty dominoes". Dominoes because what happens is that due to your initial half-assed, indecipherable "solution" in the beginning..subsequent bugs were created and as time went on they kinda just snowballed into a big clusterfuck of suck. Sort of like the domino effect, get it? Now you're stuck with no way to go forward. Where did you go wrong?

You wrote horrible code. That's where.


Make it Maintainable and Extensible.

 

Writing maintainable, extensible code can be difficult to grasp. Mostly due to the words "maintainable" and "extensible". Don't worry about these, they are just words. Just try to remember these two points when developing your apps, and if you can at all times(even in solo development), your Android app development career will be that much easier and less time consuming.

1 ) It is ALWAYS time for spring cleaning.

What I mean by this phrase is that always bear in mind that you will have to continuously clean, improve and maintain your app. Nothing is worse than having to go back and figure out what certain constructs do or what the purpose of this chunk of code is for. Design for maintainability. From the first moment you start building your app, keep this in mind. Don't add unnecessary dependencies. Don't work hard, work smart. Find the shortest but most efficient way to a solution. And if you must choose between "quick and dirty" or "long and elegant", always choose the latter. Keep related things together, and unrelated things separate. Remember that 20% of software development is making, 80% is maintaining.

2)  Think ahead. Design for the future.

Always keep the future in mind. Get into the habit of designing software that can easily adapt to future changes(if you so choose to include them), and improvements.This goes back to what we said earlier about not having too many dependencies and avoid q&d as much as possible. Imagine that if you were to remove a core feature or API from your app, would that break other parts of the program? Could it be fixed easily ?


 

  

 


 

 

Activities, Lifecycle, Callbacks...


One of the easiest but most overlooked concepts in early Android development is understanding the Activity lifecycle. If you don't know what an Activity is, don't worry. Head on over to the developer page to learn more about them. If you don't want to, that's fine too. I'll do my best to explain it here.

Basically, an Activity in Android represents a single screen/page in your app. Every Android application is made up of  at least one, but usually a few Activities. Imagine you have an app that asks the user for their username and password, logs them in, and displays their current bank account information. Let's break down what Activities that app would most likely consist of.

1) The first Activity would be the one that shows the dialog, right? The dialog could also be the Activity itself, but more on that later. Just remember that an Activity represents a single, functional screen. So for now, this is correct.

2) Now let's say that the user has entered their username and password successfully. The dialog box is removed and another screen shows up loading their bank info. This new screen represents a second Activity within the app.

That's it. You're now a master of Android's Activity class, go forth and teach to the masses.

Bicycle? "No, I said Life-cycle"
 Android's Activity lifecycle is a pivotal(note the bold and italics, that means it's impotaahhnt) concept in Android app development. It represents just what the name suggest, the "lifecycle" or different stages of an Android Activity. As we mentioned earlier, Android apps are made up of a bunch of Activities, and that each screen of the app represents a new one.

When someone's using your app, a bunch of different things can happen. What if they received a phone call while playing your game? What if they decided to respond to a text so they closed your app and went back to it after? What if another app on the user's phone is running low on memory? These and so many more things can happen at any given point while your app is being used, and as the developer you HAVE TO(remember what we said about those bold and italics) make sure that you do your best to handle these cases successfully. Trust me.

Obviously you can't account for ALL of the things that could happen while someone is using your app. What if your user is using your app while on the toilet, and accidentally drops it in? Oh well, nothing you can do about that. Hope he has a warranty.

Fortunately, Android's Activity class consists of a bunch of handy methods we can utilize to prevent  and/or handle some of the headaches mentioned above.

Callback Methods

The Activity consists of 7 "callback" methods that you need to know about and when each of them are called, in order to create a functional, user friendly application.

A callback method is basically a method(you should know what these are) that is referenced by another method, being passed in as a parameter. It is called when some specific event occurs, and  it "calls back" or returns a value to it's caller. I suggest you have a look at this Wikipedia article if you're interested in learning more about callbacks. If you are still unsure about this concept. Here's a simple  Java example that I came up with.

//A method that will be called when user clicks a button

private String onButtonClick(){

return "You clicked a button. Hooray";

}

//Method to do something
private void doSomething(String s) {

System.out.println(s);

}
//Start of the program
public static void main(String[] args){

doSomething(onButtonClick());

}

 Continuing with Activities, imagine that the calling class in this case is an activity within your app. Your activity then calls one of these methods when some specific event occurs. This occurs through and through 'til the end of your Activity.

The 7 methods are;

onCreate()
onStart()
onResume()
onPause()
onStop()
onRestart()
onDestroy()

They are easy to identify and because of their names, you get a little insight into what part of your Activity they are responsible for. Each method is invoked when a specific event occurs within your Activity. For example, onPause() handles what happens when your activity is paused and is about to go into the background. I strongly suggest that you take a look at the official Android Developer Page discussing the Activity lifecycle and it's methods.

A little about Android...

Android is a mobile operating system developed by Google in partnership with the Open Handset Alliance(OHA). The operating system is primarily designed for touch screen smartphones and tablet devices.  The OHA is basically a big group of hardware and software manufacturers. It consists of about 86 companies dedicated to "advancing open standards for mobile devices".

One of the beauties of Android is that it's Open Source. This means that the code behind the operating system is fully transparent and accessible to anyone that is interested. Google released the OS under the Apache License(see here ). This is great for the open source community, and many programmers have created custom versions of the operating system for their own personal devices or to publish as custom roms(click here for a great article on AndroidPolice about custom ROMS).

The first Android phone was sold in late 2008. That phone(HTC Dream) was shipped with the first version of the operating system(1.0) and there has been several updates since then.  Here's a breakdown of those versions, their names and release dates. Taken from the Android wiki page found here

Version Release date API level Distribution (October 2, 2012)
4.1.x Jelly Bean July 9, 2012 16 1.8%
4.0.x Ice Cream Sandwich October 19, 2011 14-15 23.7%
3.x.x Honeycomb February 22, 2011 11-13 1.9%
2.3.x Gingerbread December 6, 2010 9-10 55.8%
2.2 Froyo May 20, 2010 8 12.9%
2.0, 2.1 Eclair October 26, 2009 7 3.4%
1.6 Donut September 15, 2009 4 0.4%
1.5 Cupcake April 30, 2009 3 0.1%


Introduction

Hello there, and welcome to the blog!

First a brief introduction. My name is Jade Byfield. I'm a huge fan of Java and I've recently started developing for Android. I have to say that I love it. I'm also very passionate about graphic designing and making pretty things in PhotoShop CS5(my tool of choice). I find that app development perfectly incorporates both my passion for designing as well as writing code.

 I'm 23 years old. Born in Kingston, Jamaica. Moved to Brooklyn, New York at about age 8 and I've been living in Miami, Florida for the past 5 years.

Why even start a blog?



1) First, I wanted a dedicated space to share my passion for Android dev. I feel like talking about your ideas and sharing them with others is(sometimes) the best way for them to grow. Here I will host my apps, discuss the development process in detail, talk about issues that I encountered while developing and brainstorm future ideas. If you're interested in learning how to make the next big app and being on your way to retirement with a 7 figure bank account(lol)...then follow along. No but seriously, I think Passion in the work is far more important that any hope of financial success. Sure, we all want our ideas to do well; but let's not forget about the love for software development as well.

2) I wanted to help other developers and newbie programmers avoid some of the pitfalls that I took when I just started in the fall of 2011. I am by no means an expert, and my knowledge of the framework is growing every day as I read and learn as much as I can when I am not working. I had a little experience with Java prior to getting into Android, primarily through a few programming courses I took at university.

I believe that the best way to learn and to teach is through simplicity. There's no need to make complex things bigger when trying to explain or understand them. I remember reading books and watching videos about Android last year and wondering, "Why did you take so many words to explain that". I believe that teaching is one of the greatest skills you can learn while alive, but sadly a lot of books and other material you will come across in your journey for greater knowledge will only complicate the process even more.

"Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." ~ Albert Einstein

The purpose of this blog is simple. To share and to take share. To share what I've learned and to take away whatever knowledge I can from anyone that reads it. That's what drew me to Open Source. The resources at your disposal(especially in this age) is truly awe-inspiring. With a bit of effort and determination, it's amazing what one can learn. 


Twitter 

Stack Overflow 

That's all for now. 


Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Host