Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,593 members, 7,801,697 topics. Date: Thursday, 18 April 2024 at 08:34 PM

Beginners - Learn Android Programming - Programming (4) - Nairaland

Nairaland Forum / Science/Technology / Programming / Beginners - Learn Android Programming (22289 Views)

Learn Android App Development For FREE Here / Let Learn Android Programming Togather / Beginning Android Programming. Come Lets Start Together. (2) (3) (4)

(1) (2) (3) (4) (5) (Reply) (Go Down)

Re: Beginners - Learn Android Programming by blacksta(m): 4:58pm On Jun 02, 2011
Fayimora:

I'd prefer you restart your system.Dalvik sometimes doesn't initialize until the system is restarted,  Its optional tho. If restarting eclipse works fine then no need restarting the system

Like you have been reading my mind  - that Dalvik almost drove me crazy this afternoon  but finally sorted out  grin


Lesson 3.0 - Fun Part start tomorrow - or later after i chop Eba -
Re: Beginners - Learn Android Programming by Fayimora(m): 5:09pm On Jun 02, 2011
heheheh, yeah so anyone finding it difficult installing the stuffs blacksta explained above?
Re: Beginners - Learn Android Programming by gifted: 8:31pm On Jun 02, 2011
Cannot wait for 3.0
Re: Beginners - Learn Android Programming by zeeleso(f): 1:43pm On Jun 03, 2011
Fayimora:

Blacksta is ryt. Its not all about the code. YOu havent event set up your environment so what you wanna do with code? By the way only the basics would be taught, Its left for you to do whatever you want to do with it
I have set up my environment and started trying out some children things on top it, you know how developers are can be sometimes impatient. .*slaps self on the face*., no b my fault its the developer in me.

As i was saying, *clears throat*, ermm, WHERE ARE the codes, *runs away to hide*
Re: Beginners - Learn Android Programming by Fayimora(m): 1:55pm On Jun 03, 2011
Just want to state this again, You must be at least an INTERMEDIATE(understand fully the OOP concepts) in Java and you MUST also have a general understanding on XML. PLease don't even bother partaking in this tuts if you don't have these qualities I just mentioned. Am not trying to be rude or bossy but the face is the purpose here should be android development and not java or xml. So in essence asking things like what is an object or how to you write a loop(Java) or what is an attribute, a child element(XML) would not be part of this. It is assumed that you already know these.

The person teaching you (Blacksta) is oing a good job. As far as am concerned he has even done too much. I would only be following up to make sure the pace is kept. Sometimes because you are good at something you forget that you are teaching beginners and skip somethings. I would just follow up such issues.

I wish y'all happy learning!!!
Re: Beginners - Learn Android Programming by blacksta(m): 2:14pm On Jun 03, 2011
Fayimora:

Just want to state this again, You must be at least an INTERMEDIATE(understand fully the OOP concepts) in Java and you MUST also have a general understanding on XML. PLease don't even bother partaking in this tuts if you don't have these qualities I just mentioned. Am not trying to be rude or bossy but the face is the purpose here should be android development and not java or xml. So in essence asking things like what is an object or how to you write a loop(Java) or what is an attribute, a child element(XML) would not be part of this. It is assumed that you already know these.

The person teaching you (Blacksta) is oing a good job. As far as am concerned he has even done too much. I would only be following up to make sure the pace is kept. Sometimes because you are good at something you forget that you are teaching beginners and skip somethings. I would just follow up such issues.

I wish y'all happy learning!!!

Thank you sir - Your inputs have been have also been very valuable




Lesson 3.0 - Write my first HelloWorld

to make sure your environment is correctly set up

try out the following

1. Start Eclipse - Choose file - New -Android Project

Project Name - HelloWorld

in the build target - select the Android device (emulator) - I chose " Android 2.2"

Application name - HelloWorld!!!

Package Name- NL.com

Activity - Optional

Mini SDK version - Is the minimum version of Android as represented by APi Level - I am Using " 8"

and click finish
Re: Beginners - Learn Android Programming by ishekinah1(m): 2:23pm On Jun 03, 2011
Ilove this post.
@Faymora or anybody i need the soft copy of visual csharp how to program.
email. allthingsarepossible07@yahoo.com
THANKS all
Re: Beginners - Learn Android Programming by Fayimora(m): 2:30pm On Jun 03, 2011
Step 1


Step 2(Project name, Up to you but its best you use the applications name wink)


Step 3(I have all SDK's and API's here so use what you have or what blackstar is using)
Re: Beginners - Learn Android Programming by blacksta(m): 2:41pm On Jun 03, 2011
-  

The above process should automatically generate a number of files

1. MANIFEST FILE

This file glues everything together  - it is this file that explain what the application consisit of , what all the its main building block and persmissions it reques


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="nl.com"
     android:versionCode="1"
     android:versionName="1.0">
   <uses-sdk android:minSdkVersion="8" />

   <application android:icon="@drawable/icon" android:label="@string/app_name">
       <activity android:name=".nl"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>

   </application>
</manifest>



2. LAYOUT XML Code -  The layout file specifies the layout of your screen


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
<TextView  
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="@string/hello"
   />
</LinearLayout>


3. STRINGS --  This is another file that contains all the text that our application uses - for example  buttons, labels, default text


<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="hello">Hello World, Welcome to Nairaland Android Tutorial!</string>
   <string name="app_name">Hello World - NairaLand Tutorial</string>
</resources>

4. R FILE  - this file is join btw the java world and Android world of resources  ( Never Never modify)

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found.  It
* should not be modified by hand.
*/

package nl.com;

public final class R {
   public static final class attr {
   }
   public static final class drawable {
       public static final int icon=0x7f020000;
   }
   public static final class layout {
       public static final int main=0x7f030000;
   }
   public static final class string {
       public static final int app_name=0x7f040001;
       public static final int hello=0x7f040000;
   }
}



5. Java Source Code -  this one drive everything  - this code get converted to a DALVIK executable and runs the application

package nl.com;

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

public class nl extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
   }
}
Re: Beginners - Learn Android Programming by blacksta(m): 3:06pm On Jun 03, 2011
Run the Emulator on pc- it mimics the actual device  - for example HTC desire.

to use the emulator  - we have to create an Android Virtual device . via Eclipse


1. Start the tool called Android SDK and AVD Manger

2. window pops open  - select New

Name - myAndroidPhone

target -  Android 2.2 API level 8


3. click on Create AVD

4. Select the newly created emulator and select  START


With Emulator running  -  run the HelloWorld java application

Re: Beginners - Learn Android Programming by zeeleso(f): 3:28pm On Jun 03, 2011
Now we r talking.
Quick question ,how do i test it on my physical android device?
Re: Beginners - Learn Android Programming by blacksta(m): 3:35pm On Jun 03, 2011
Can you spot the Nairaland App

Re: Beginners - Learn Android Programming by blacksta(m): 3:40pm On Jun 03, 2011
zeeleso:

Now we r talking.
Quick question ,how do i test it on my physical android device?

http://developer.android.com/guide/developing/device.html
Re: Beginners - Learn Android Programming by blacksta(m): 9:01am On Jun 05, 2011
Main Building Blocks of Android

Thesse are components that you can use as an application developer to build android apps

Your design process (top down approach ) Screens  ---   Features  and the interactions btw them

ACTIVITies

An activity is usually a single screen that users sees on the device at one time.

Activity Life Cycle

activities may involve creating a linux process, allocating memory, setting up the whole screen and mamy more.  To effectivitely manager all these process  the activity life is managed by the Activity Manger.

Activity Manager is responsible for creating, destroying and managing activites

Re: Beginners - Learn Android Programming by blacksta(m): 9:14am On Jun 05, 2011
More of Android Building Blocks


Intents   These are messages sent among the major blocks - e,g  they trigger an activity to start up or tell a service to start or stop.  Intents are asynchronous. 

Example

1. Launch Gmail app - select mail

2 with mail displayed  - you click on the http link

3 http link launches web browser

4  Within browser  - you click on youtube link which launches Youtupe App



Services

Services run in the background and dont have any UI and can perfom same actions as activities .

Example

Listening to music in the background while main activity o screen is browsing the web

Content Providers

are interfaces for sharing data between application.

Example

All your media ( pictures , music, ringtones ) are stored in a central location - is made available to apps  rather than  music player app having it own database. it simply taps into the central location.
Re: Beginners - Learn Android Programming by blacksta(m): 9:34am On Jun 05, 2011
Broadcast Receivers This reciever is simpy dormant code that get activated once an event to which it is subscribed happes

Example

SMS arrives or A Call comes in

Application Context refers to the application environment and the process within which all components are running.

In short Activities, Services, Content Providers and broadcast receivers together make up an application
Re: Beginners - Learn Android Programming by blacksta(m): 9:48am On Jun 05, 2011
The best way to learn is by Example -   We going to build a NL twitter-Like application.

first task " the Status Update screen" The task involves building an ACTIVITY , networking and Multithreading and debugging.

2 ways to create an inteface.

1. Declarative User interface -

Using XML to declare what the UI will look like similar to HTML

2. Programmatic User Interface

Using java code to develop UI - very similar to Java AWT or Java Swing

for the sake of our app creation - the two ways will be used.
Re: Beginners - Learn Android Programming by Fayimora(m): 8:35pm On Jun 05, 2011
hey guys sorry been offline, Was banned by the bot spam filter for my above images for almost 3 days, Am back on track
Re: Beginners - Learn Android Programming by Nobody: 9:23pm On Jun 05, 2011
^
How the hell can a moderator be banned?
Re: Beginners - Learn Android Programming by Fayimora(m): 10:15pm On Jun 05, 2011
You might want to ask the auto spam filter, lol
Re: Beginners - Learn Android Programming by blacksta(m): 8:16pm On Jun 06, 2011
Tip  - 1

Android organizes its UI elements into Layout and views. eg buttons, labels or textbox is a view  while LAYOUTS organise views. for example grouping together a button and label.

Layouts

1. LinearLayout
2.TableLayout
3FrameLayout
4 Releative and absolute layouts


Moving on - To create our twitter like Application   - open up eclipse IDE

cLICK file  - New - Project - Android  - you should see the below

once you have entered the necessary - click finish

Re: Beginners - Learn Android Programming by blacksta(m): 8:52pm On Jun 06, 2011
By default eclipse created a file called main.xml - ( it is under res/layout folder)

Our twitter like App we have the following

1 a title at the top of the screen

2. a big text area to type our 140 characters

3. a button to click update status

4 a layout to contain all the widgets
Re: Beginners - Learn Android Programming by blacksta(m): 9:45pm On Jun 06, 2011
Making some adjustment to the main.xml - Our Twitter App is taking shape



<?xml version="1.0" encoding="utf-8"?>

<!-- Main Layout of Status Activity -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<!-- Title TextView -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center"
android:textSize="30sp" android:layout_margin="10dp"
android:text="@string/titleStatus"/>

<!-- Status EditText -->
<EditText android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"
android:hint="@string/hintText" android:id="@+id/editText"
android:gravity="top|center_horizontal"></EditText>

<!-- Update Button -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/buttonUpdate"
android:textSize="20sp" android:id="@+id/buttonUpdate"></Button>

</LinearLayout>

Re: Beginners - Learn Android Programming by blacksta(m): 10:36am On Jun 09, 2011
Please leave feedback - How would you rate this thread - Thanks


More to follow - shortly - At the moment busy with work / Wifey Drama grin
Re: Beginners - Learn Android Programming by Erel: 7:37am On Jun 16, 2011
You might want to try Basic4android. It is much simpler to get start with.

http://www.youtube.com/watch?v=p4wh0IksOfg
Re: Beginners - Learn Android Programming by blacksta(m): 10:07am On Jun 22, 2011
Hey - I am back - Lets do it grin
Re: Beginners - Learn Android Programming by 3kay945(m): 8:39am On Jul 02, 2011
Pls let continue o
Re: Beginners - Learn Android Programming by Nov1ce(m): 4:17pm On Jul 11, 2011
Hey blacksta,
Ur doing a pretty good job here.
Re: Beginners - Learn Android Programming by Mobinga: 11:48am On Dec 11, 2011
I think its awesome if you have an android device, you don't need that[b] rubbish nonsense slow android emulator[/b]. All you need to do is plugin your device turn on USB debugging and watch how you develop and run on a physical device. cool
Re: Beginners - Learn Android Programming by Fayimora(m): 3:31am On Dec 12, 2011
Yeah true. Am surprised google still hasn't done anything about it, Anyways seems this tut has gone down the drain
Re: Beginners - Learn Android Programming by tuazor: 5:48pm On Dec 15, 2011
i realy love what you guyz are doing here. God bless you and your knowledge. i am a programmer, though a beginner. please i want to ask if i can follow this forum working with the examples you've placed using JAVA SE and NETBEANS IDE. its the one i have installed on my system and its what am programming with. keep it up guyz there is future for young programmers.

an urgent answer to my question will be of a great help.

@blacksta, fayiroma. you guyz are doing great. more grace.

one love!

please on my system am working with
* JAVA2 SE and
* NETBEANS IDE. 6.0 VERSION

(1) (2) (3) (4) (5) (Reply)

Help Me Write The Quadratic Equation (almighty Formula) In This Languages / Please Rate This: My First Data Visualization Project / Can I Learn Programming From My Android Phone?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 62
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.