Thursday, March 10, 2016

Lesson 3. Creating AVD. The first application. Android project structure

In the Target list Android platforms of different versions are presented. We've downloaded them in previous lesson as the last step. Choose the right version and see the information about it.

Return to Eclipse. Let’s choose platform 2.3.3 (API Level 10) from the list. And let’s give it the corresponding name - AVD_233. Let’s also specify the size of SD Card = 100 andHVGA Screen mode.
Press Create AVD and close AVD Manager
Finally, we can create our first application and see how it works.

There multiple versions of wizard for creating a project as Google constantly changes them! Look for the one that suits you the best. They are sorted by date, the newest first.

Version from 12/11/2012

In Eclipse go to File New Project
Choose the project type - Android Android Application Project, click Next

The window for creating a project appears.
Let’s fill it in.
Let’s begin with a Project Name - it is the name of the project that will be displayed in the list of projects on the left. As we will have many projects, I propose to think up a prefix for names. It would be easier to return to older projects and they will be structured nicely and conveniently.
The prefix can be like this: P<lesson number(000)><lesson project number(0)>. We will leave three numbers for the lesson number and one for the project number. Let’s add some logical name to the prefix (OurFirstProject) and we will get the name of our first project of the third lesson - P0031_OurFirstProject.
Application name - it’s directly the name of the application, which will be displayed in the device application list. We can specify the project name without a prefix.
Package name - Java term, explained in details here. Shortly, it is a prefix for classes names of our application. I will be using ru.startandroid.develop.<application name>

Minimum Required SDK defines the minimum Android Version within which the application will launch. Let’s choose the same as while creating AVD - 2.3.3.
Compile With defines the abilities of which Android version will the application use. Specify 2.3.3 here.
Target SDK defines the maximum Android version, on which you have tested your application. It’s required for compatibility modes. Specify also 2.3.3 here.
Do not specify a Theme for now, choose None

Click Next

From ticks leave only
Create Activity - immediately after the project creation the Activity will be created, not to create it manually.
Create Project in Workspace. Project will be created and saved in the default workspace.
Click Next

Choose BlankActivity
Click Next

Make sure here, that in field Activity Name MainActivity is specified, and in field Layout Name enter main. Navigation Type - None.
Click Finish.
The project has been created.


07/10/2012 Variant

In Eclipse go to File New Project
Choose the project type - Android Android Application Project, click Next
The window for creating a project appears.
Let’s fill it in.
Let’s begin with a Project Name - it is the name of the project that will be displayed in the list of projects on the left. As we will have many projects, I propose to think up a prefix for names. It would be easier to return to older projects and they will be structured nicely and conveniently.
The prefix can be like this: P<lesson number(000)><lesson project number(0)>. We will leave three numbers for the lesson number and one for the project number. Let’s add some logical name to the prefix (OurFirstProject) and we will get the name of our first project of the third lesson - P0031_OurFirstProject.
Application name - it’s directly the name of the application, which will be displayed in the device application list. We can specify the project name without a prefix.
Package name - Java term, explained in details here. Shortly, it is a prefix for classes names of our application. I will be using ru.startandroid.develop.<application name>
Build SDK defines the abilities of which Android version will the application use. Let’s choose the same as while creating AVD - 2.3.3.
Minimum Required SDK defines the minimum Android Version within which the application will launch. Let’s make it the same as Build SDK - 2.3.3.
From ticks leave only Create Project in Workspace. The project will be created in the default workspace.

Click Next
The window for Activity creation opens.
Choose BlankActivity here and click Next.

Make sure here, that in field Activity Name MainActivity is specified, and in field Layout Name enter main. Do not touch other fields.
Click Finish
The project has been created.

Old variant


In Eclipse go to File New Project
Choose the project type - Android > Android Application Project, click Next
The window for creating a project appears. In newer versions this window is splitted into three.
Let’s fill it in.
Let’s begin with a Project Name - it is the name of the project that will be displayed in the list of projects on the left. As we will have many projects, I propose to think up a prefix for names. It would be easier to return to older projects and they will be structured nicely and conveniently.
The prefix can be like this: P<lesson number(000)><lesson project number(0)>. We will leave three numbers for the lesson number and one for the project number. Let’s add some logical name to the prefix (OurFirstProject) and we will get the name of our first project of the third lesson - P0031_OurFirstProject.
Build Target defines the abilities of which Android version will the application use. Let’s choose the same as while creating AVD - 2.3.3.
Application name - it’s directly the name of the application, which will be displayed in the device application list. We can specify the project name without a prefix.
Package name - Java term, explained in details here. Shortly, it is a prefix for classes names of our application. I will be using ru.startandroid.develop.<application name>
Create Activity - the name of Activity class (application screen). Let’s specify MainActivity for instance.

Leave everything else as it is. Click Finish.
The project has been created.


Screenshots below may differ for different versions but not much.
On the left our project appeared, let’s expand the project. We will look through the most important and frequently used folders and files.

src - all our written source code will be situated in this folder
gen - filed generated by the environment that the application requires. You better not touch anything here. (If there is no such folder - edit something in the project and clickSave button).
Android 2.3.3 - Android libraries required for the application
assets and res - folders for resource files of different type
AndroidManifest.xml - manifest or configuration file of the application

We will use all this later and it will be clear what it’s needed for.

Select the project name on the left.
and let’s run it - press CTRL + 11,
then choose Android Application
click OK.
The emulator will be launched, I advise not to touch or press anything, because it’s laggy and unstable thing. Startup time is approximately one minute. Wait until the following strings appear in Eclipse console.

The application is installed on the emulator and is running. Unlock the emulator screen (if it is locked) and observe our application.
You can see the name of the application and the name of the Activity. We have just created and launched our first application.
If you didn’t manage to launch it and there is a message like this in Eclipse console "emulator-5554 disconnected! Cancelling 'ru.startandroid.develop.OurFirstProject.MainAct activity launch'!" - close the emulator and try again. If you didn’t manage to do it again - restart Eclipse. If failed again - reboot. If it doesn’t work even now - delete the AVD and create a new one. Finally it should work, even if not from the first try.
The main thing here - after running the application (CTRL + F11) try to make as few motions as you can on your computer. I have spotted a clear tendency - if you switch different windows while emulator is starting, it launches with faults. But if you sit and wait for a minute - everything would be fineAnd turn off all the other procedures like video rendering that load the system. 
You can read about the emulator in more detail here.
Related Articles:

Wednesday, March 9, 2016

Lesson 2. Installing and configuring development environment Eclipse and SDK Tools

1. Java SDK - JDK

As program development is in Java, we have to download and install the appropriate SDK, which is also called JDK (if it isn’t already installed, of course).
You can download it here. Version seven appeared recently. Can’t say anything about it, but some people think that it’s quite raw, that’s why I recommend using reliable version six. In the Java PlatformStandard Edition press JDK Download, tick the checkbox that you accept the licence agreement and download the file according to your operating system. There shouldn’t be any problems with installing Java SDK. After the installation you should reboot your computer.

So there are two ways to get ready to development IDE, wich consists of Eclipse IDE, Android SDK and ADT.
The first one - to download it here (Download for other platforms -> ADT Bundle) and choose the link for your version. Than you extract it and run ..\eclipse\eclipse.exe. In Eclipse you run SDK Manager (menu Window > Android SDK Manager) and go to the item number 5 of this lesson to download platformes.
The second way. If you want to install and configure manually, read further.

2. Android SDK

Android SDK includes tools that are necessary for Android application development. You can download tools here (Download for other platforms -> SDK Tools Only), choose link for your operation system. It’s recommended to download an .exe file, but I propose you to download ZIP-version and extract it into a convenient folder for you.
Note that it should be a directory "forever". You better not move this folder anywhere, because you would have to reconfigure development environment. I recommend creating directory Android somewhere. It’s highly recommended for the path to this directory to be short. <Disc name>:\android would be perfect (it’s f:\android as for me). Further we will refer to this directory as <Android>. Let’s extract our archive into this directory and we will get <Android>\android-sdk-windows.

3. Eclipse

It’s fancy and convenient development environment in which we will build and create ). We will take it from here. Google recommends us Eclipse Classic version. Let’s accept this proposal  and download this version. Now extract the archive into <Android> and we will have <Android>\eclipse

4. ADT

By default Eclipse is not really good suited for Android application development. ADT is a plugin that configures the environment to use Android SDK and enables convenient development.
Launch Eclipse (<Android>\eclipse\eclipse.exe). When you launch Eclipse for the first time it will ask you for a working directory where it will store project files. Again, I propose not to walk far away, create <Android>\workspace directory and choose it.

Ok, now Eclipse is running. Let’s download ADT plugin.
Go to Help -> Install New Software

Press Add button in the upper right corner

Enter "ADT Plugin" in the Name field.
Enter URL https://dl-ssl.google.com/android/eclipse/  address in the Location field.

Press OK and wait until Developer Tools appear (If there are any troubles use http instead of https)
Tick Developer Tools and press Next.

Now we can see the components that will be installed, press Next again.

Read and accept the licence agreement and click Finish.

The download of components is starting. If the Security Warning that the authenticity or validity of the software can’t be established pops up, click OK.

On my computer the process lasted approximately a minute.
After it is finished you have to restart Eclipse - Restart Now

After restarting Eclipse if shows the following dialog:
The first item is for those who, for some reason, didn’t download and install SDK in the second step of these instructions. Eclipse can do it on its own. And additionally it will download the latest android platform. It also offers to download 2.1 platform as the most widely supported platform.
We are interested in the second item - it allows us to point there we extracted in the step 2. It’s <Android>\android-sdk-windows. Press Next
In the window that appear choose whether to send statistic to google or not. It will not influence the work at all.
Choose Yes or No and click Finish.
Then we are informed that our SDK Platform Tools component is missing and they offer us to go to SDK Manager and download it. Press OK.

5. Android Platforms

Let’s launch SDK Manager
It is proposed to choose components for download via the internet. On the right side for each component is stated whether it’s downloaded or not. Ok, so what will we download?
It is obligatory to download the contents of the Tools folder that hasn’t been downloaded yet. Also in the Extras folder (at the end of the list) tick Android Support Library item if it’s there.
For all the other Android versions you need tick only SDK Platform. Take into account that each platform can weight up 150 MB!!! If you do that at work system administrator will come for you :) For the first lessons we will need only platforms 2.2 (API 8) and 2.3.3 (API 10). For now you can download only them.
For platforms with versions 4.X choose SDK Platform and ARM EABI v7a System Image (for work with emulator).

If you have enough traffic add these items for each platform:
Samples for SDK - source code of sample applications
Google APIs by Google Inc. - this is needed if you would like to work with Google applications (Maps, Navigation etc.)
If you don’t care about the traffic at all - tick everything. But you will have to wait for a long time. And it would weigh more than one gigabyte.
When you have selected everything - click Install X packages in the bottom right corner.

In the new window we accept that you want to download it all - Accept All. Here you can also see the size of components and reject some.

Press Install - the indicator was displayed and the log opened. With my choice of components, I’ve been waiting for 20 minutes. After this process the phrase Done Loading Packages appeared.
The installation has finished. Close the log and SDK Manager.
Just for the info - my new components weighted 1,5 GB.
After this restart Eclipse and that’s it. After performing these steps we have got a development environment in which we can code Android applications. Maybe these actions may seem dull and boring but, unfortunately you cannot avoid this. It will be much more fun further. If something doesn’t work or the error pops up - try googling it, you are for sure not the first one who is facing this problem and there is already a solution on the internet. Or write on the forum.
In the next lesson we will setup Android Virtual Device (AVD) in Eclipse, create our first application and launch it. AVD is a smartphone emulator with Android operating system, where you can run and test your applications. So there is no point connecting your smartphone each time ) We will also look through the application structure.

P.S.
If the following window didn’t appear:
or you accidentally closed it - everything is fine. You can specify SDK directory manually.

In Eclipse go to Windows -> Preferences

Choose Android on the left, click Browse

Specify the directory where we extracted SDK - <Android>\android-sdk-windows. Click Apply.

We are told that the component is missing - close this message and click OK

I got this window popped up:
It informs, that if we want to improve the product, we can send Google the usage statistics. It’s up to you and you can always change it in your preferences. I left the tick, I am not greedy )

Related Articles:

Tuesday, March 8, 2016

Introduction of android

Introducing the Android Platform

  • Establishing the development environment
  • Analyzing components of the architecture

Leveraging Application Fundamentals

Building mobile applications

  • Creating activities to process user input
  • Implementing views to build the User Interface (UI)
  • Packaging applications for deployment
  • Developing unit tests

Supporting asynchronous behavior

  • Performing background tasks with services
  • Communicating with intents

Creating User Interfaces

Selecting visual components

  • Building the layout
  • Connecting a view to an activity
  • Positioning form elements

Working with resource declarations

  • Declaring component definitions and layouts
  • Handling multiple screen resolutions
  • Localizing applications

Processing User Input

Communicating with the user

  • Creating and displaying Toast
  • Generating status bar notifications
  • Logging key application events

Interacting with the UI

  • Responding to user input events
  • Launching activities with intents
  • Writing Java event handlers
  • Generating context and option menus

Managing the activity life cycle

  • Integrating with the Android system
  • Persisting data in response to notifications

Persisting Application Data

Selecting storage options

  • Contrasting internal and external storage locations
  • Saving application configuration with SharedPreferences

Manipulating the SQLite database

  • Executing queries to locate information
  • Specifying column selections with projections

Consuming and creating content providers

  • Accessing shared data resources
  • Addressing content providers with URIs

Maintaining System Responsiveness

Avoiding Application Not Responding (ANR) errors

  • Unloading the UI thread
  • Designing for asynchronous execution

Building background services

  • Launching IntentServices
  • Declaring services in the manifest

Exchanging Data over the Internet

Interacting with server-side applications

  • Synchronizing Android devices with servers
  • Communicating via HTTP clients

Developing clients for web services

  • Connecting to RESTful services
  • Creating and parsing JSON

Enhancing the User Experience

Incorporating the Action Bar

  • Manipulating objects with drag and drop
  • Supporting orientation and multiple screen resolutions with resources
  • Combining fragments into a multi-pane UI

Leveraging geolocation and mapping capabilities

  • Plotting positions on Google Maps
  • Establishing location through GPS, Cell-ID and WiFi

Monday, March 7, 2016

Android training full course content

Coures: Android

Duration: 2 months

Time: 3days/week (2 hour per class)




ANDROID

 App Development Training

We OPEN EYES IT SOLUTION  started android training from last few years and successfully placed students in different IT organization. We train students from professional Android Developers who have minimum 5 years working Experience. The open-source, Linux-based and hardware-independent Android mobile OS, with the new updating release is giving mobile developers a whole new ball court to play in. Android is the fastest growing mobile OS among its competitors and with its share in the Smartphone user market growing, Android is attracting more and more enthusiastic developers.
JAVA CONCEPTS
  • Introduction to Android
  • OOPs Concepts
  • Inheritance in detail
  • Exception handling
  • Packages & interfaces
  • JVM & .jar file extension
  • Collections – HashTable,Vector,,List, ArrayList, HashMap
  • Multi threading(Thread class & Runnable Interface)
SQL
  • DML & DDL Queries
  • What is Android?
  • Setting up development environment
  • Dalvik Virtual Machine & .apk file extension

Fundamentals:

  • Basic Building blocks – Activities,Services,Broadcast Receivers & Content Providers
  • UI Components- Views & notifications
  • Components for communication -Intents & Intent Filters
  • Android API levels(versions & version names)
Application Structure (in details)
  • AndroidManifest.xml
  • uses-permission & uses-sdk
  • Activity/services/receiver declarations
  • Resources & R.java
  • Assets
  • Android Training Course Syllabus
  • Values – strings.xml
  • Layouts & Draw able Resources
  • Activities and Activity lifecycle
  • First sample Application
  • Deploying sample application on a real device
Emulator Android Virtual Device
  • Launching emulator
  • Editing emulator settings
  • Emulator shortcut
  • Logcat usage
  • Introduction to DDMS
  • File explorer
  • Second App :- (switching between activities)
  • Develop an app for demonstrating the communication between Intents
Android widgets
  • Basic UI Component and Ui Properties
    1. TextView
    2. Button
    3. EditText
    4. Spinner
    5. CheckBox
    6. Radio Button
    7. ImageView
  • Listview and Adapter and View Holder Pattern
  • Gridview and adapter
  • Listview with custom Adapter
  • GridView with Custom Adapter
  • View Pager
  • Progress bar
Design User Interface
  • User Interfaces :
    1. Drawable
    2. Shape
    3. Selector
  • Using Font Icons.
  • Styles/Themes
  • Review week one, Two and Git Basics
  • Assignment: Survey App using different UI component /Listing Popular Programming language / Shopping List Task App
Dialogs

  • Alertdialog /Dialog/Toast
  • Custom Dialog
  • Custom Toast Message
Why UI Thread and Background Thread 
  • Thread /Runnable Handler
  • AsyncTask With examples
  • Service
Interacting with hardware
  • Working with camera (taking pictures and saving it to gallery)
  • Alarm application with vibration and and sound
Data Storage: How and when to use(Real time Scenarios)
  • Share Preferences
    • File Storage
      1. Reading and Writing Sd card
    • Database : SQLite
      1. SQLite Basics
      2. Creating database
      3. CRUD operation
    • Assignment: Database Related Project. Taking input from the Form and saving it to the Database and Display the information Listview.
Data Exchange format
  • Json/Xml
  • Parsing Json data with examples
  • Parsing json using Google Gson lib
Handling Network Connection
  • REST API Connection using basic DefaultHttpclient
  • REST API Connection Using third party Library – Volley
  • Loading remote images using Picasso Library.
Some Advance topics(Brief)
  • What is Material designs and its implementation.
  • Adding Navigation Drawer
  • RecyclerView and Adapter/ LayoutManager class
Google Map
  • Introduction to Google Map
  • Implementation 
Final Project
  • Create a Final Android Application and publish to Google Play and Openshift

Summary of Key Learnings
  • Learn the core concepts of an object‐oriented programming language (Java)
  • Develop programming skills by building Native Android Mobile Apps
  • Implement your applications
  • Develop Android based Apps and sell Android Apps in the marketplacewith Live Industrial Project
  • Understand theAndroid OS, UI and Design requirements
  • Learn Android Storage
  • Deploy the application in the marketplace to show during interviews and in Final semester Viva presentation.
Pre-requisites Eligibility
  • Candidates with understanding of C, C++ can undergo this training. Core Java

Related Articles: