First Program - Hello Geeks

Whats up Geeks,

In this tutorial we are going to learn our first Android App program, i.e Hello Geeks program.

From our last tutorial we will be able to create a new android project. Now lets see how to run it on an emulator.

Steps to be followed:
  • First we need to create an AVD (Android Virtual Device). An AVD is a device configuration for the Android Emulator that allows you to model different devices.
    To create an AVD:
    1. Launch the Android Virtual Device Manager:
      1. In Eclipse, click Android Virtual Device Manager from the toolbar.
      2. From the command line, change directories to <sdk>/tools/ and execute:
        android avd
    2. In the Android Virtual Device Manager panel, click New.
    3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
    4. Click Create AVD.
    5. Select the new AVD from the Android Virtual Device Manager and click Start.
    6. After the emulator boots up, unlock the emulator screen.
To run the app from Eclipse:
  1. Open one of your project's files and click Run from the toolbar.
  2. In the Run as window that appears, select Android Application and click OK.
In this way you will be able to run your first Android App.

Setting up environment for Android App Development

Whatsup Geeks,

Lets start our learning on Android App Development. An android project contains all the files that comprise the source code for the Android App.
Android SDK provides all the set of default project directories and files.
Before starting building an android app please ensure that Android SDK is updated with atleast one package installed, and if you're using Eclipse, you should also have the ADT plugin installed (version 22.6.2 or higher). If you don't have these, follow the guide to Installing the Android SDK, Setting up ADT plugins and Adding Platform and Packages step before we start our project development.


If all the above steps are completed, then its great. We can now proceed with our first project.

Creating a project with Eclipse:

When we double click on Eclipse icon present at desktop. It will ask for the Workspace.

Create a folder for your workspace and then check "Use this as the default and do not ask again" for using that Workspace location as default.

Then follow below steps to create your first Android App:
  1. Click File -> New in the toolbar (Shortcut Alt+Shift+N).
  2. In the window that appears next,  
    •  Select the Android Application Project.  
          Else
    •   Select Project option for Android Application Project/ Android Project from Existing  Code/ Android Sample Project.
     3.  Fill in the form that appears: 
    • Application Name is the app name that appears to users. For this project, use "My First App." 
    • Project Name is the name of your project directory and the name visible in Eclipse. 
    • Package Name is the package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. For this project, you can use something like "com.example.myfirstapp." However, you cannot publish your app on Google Play using the "com.example" namespace. 
    • Minimum Required SDK is the lowest version of Android that your app supports, indicated using the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the app's core feature set, you can enable the feature only when running on the versions that support it (as discussed in Supporting Different Platform Versions). Leave this set to the default value for this project. 
    • Target SDK indicates the highest version of Android (also using the API level) with which you have tested with your application.
    • As new versions of Android become available, you should test your app on the new version and update this value to match the latest API level in order to take advantage of new platform features. 
    • Compile With is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. (It should be Android 4.1 or greater; if you don't have such a version available, you must install one using the SDK Manager). You can still build your app to support older versions, but setting the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.
    • Theme specifies the Android UI style to apply for your app. You can leave this alone.
    • Click Next.
    • On the next screen to configure the project, leave the default selections and click Next.
    • The next screen can help you create a launcher icon for your app.
    • Click Next.
    • Now you can select an activity template from which to begin building your app.For this project, select BlankActivity and click Next.
    • Leave all the details for the activity in their default state and click Finish.

Adding Platform and Packages

Steps for adding platform and packages :

  • Launch the SDK Manager, by double clicking on SDK Manager.exe file at the root of the Android SDK directory.
  • The SDK Manager shows all the SDK packages available for you to add to your Android SDK. As a minimum configuration for your SDK, we recommend you install the following:
    • The latest Tools packages (check the Tools folder).
    • The latest version of Android (check the first Android folder).
    • The Android Support Library (open the Extras folder and check Android Support Library).
    Once you've chosen your packages, click Install. The Android SDK Manager installs the selected packages into your Android SDK environment.


    Then restart the eclipse. And get started.

Setting Up Android Bundle

We will start with the setting up Android Bundle. The ADT (android Developer Tools) Bundle provides everythinng for developing apps.

Getting started on Windows

Steps:

-> Before setting up Android Bundle, please insure that latest Java SE Development Kit (JDK) is
     installed.

-> Install the eclipse from eclipse.org/downloads/

-> Then Download the ADT Plugins. And follow below steps to integrate to eclipse:

  • Start Eclipse, then select Help -> Install New Software.
  • Click Add, in the top- right corner.
  • In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
    Note: The Android Developer Tools update site requires a secure connection. Make sure the update site URL you enter starts with HTTPS
  •  Click OK.
  •  In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  •  In the next window, you'll see a list of the tools to be downloaded. Click Next
  •  Read and accept the license agreements, then click Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  • . When the installation completes, restart Eclipse.

If facing trouble in setting ADT plugins. Follow below steps:

  • Download the ADT Plugin zip file (do not unpack it):
    Package Size MD5 Checksum
    ADT-22.6.3.zip 14590813 bytes 3982259fd2cc81e53bbbe05dcd6529a7 
  • Start Eclipse, then select Help > Install New Software.
  • Click Add, in the top-right corner.
  • In the Add Repository dialog, click Archive.
  • Select the downloaded ADT-22.6.3.zip file and click OK.
  • Enter "ADT Plugin" for the name and click OK.
  • In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  • In the next window, you'll see a list of the tools to be downloaded. Click Next.
  • Read and accept the license agreements, then click Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  • When the installation completes, restart Eclipse.

Android SDK Installations

Get the Android SDK

The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.
If you're a new Android developer, we recommend you download the ADT Bundle to quickly start developing apps. It includes the essential Android SDK components and a version of the Eclipse IDE with built-in ADT (Android Developer Tools) to streamline your Android app development.
With a single download, the ADT Bundle includes everything you need to begin developing apps:
  • Eclipse + ADT plugin
  • Android SDK Tools
  • Android Platform-tools
  • The latest Android platform
  • The latest Android system image for the emulator


ADT Bundle
Platform Package Size MD5 Checksum
Windows 32-bit adt-bundle-windows-x86-20140321.zip 535085536 bytes b61495a6bf591cc374c31bce4fc46ec0
Windows 64-bit adt-bundle-windows-x86_64-20140321.zip 535287324 bytes a6f4699bbdc5a29b371ed60610535651
Mac OS X 64-bit adt-bundle-mac-x86_64-20140321.zip 501955296 bytes 4a08649cea9b098cdf7349f452294014
Linux 32-bit adt-bundle-linux-x86-20140321.zip 527971926 bytes 943ae4d28fe7c79108c8bf2aafd5e6d2
Linux 64-bit adt-bundle-linux-x86_64-20140321.zip 528187678 bytes f2a2153b5c7dbaeb86b550bf4f770c36


SDK Tools Only
Platform Package Size MD5 Checksum
Windows
32 & 64-bit
android-sdk_r22.6.2-windows.zip 108917505 bytes 6e5bfdb7b9c1d231ed6ec78b31551cbf
installer_r22.6.2-windows.exe (Recommended) 87383126 bytes 2a68b8b22ecd0aba779b1581a914b395
Mac OS X
32 & 64-bit
android-sdk_r22.6.2-macosx.zip 74639394 bytes 2a319c862dd1dcf450bfe2a6b3d9c608
Linux
32 & 64-bit
android-sdk_r22.6.2-linux.tgz 101050024 bytes ff1541418a44d894bedc5cef10622220


For latest updates please visit Android SDK



















About Android

About Android

Android is an operating system based on the Linux kernel with a user interface based on direct manipulation, designed primarily for touchscreen mobile devices such as smartphones and tablet computers, using touch inputs, that loosely correspond to real-world actions, like swiping, tapping, pinching, and reverse pinching to manipulate on-screen objects, and a virtual keyboard. Despite being primarily designed for touchscreen input, it also has been used in televisions, games consoles, digital cameras, and other electronics

 
Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It's the largest installed base of any mobile platform and growing fast—every day another million users power up their Android devices for the first time and start looking for apps, games, and other digital content.

Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

Features


Interface

Android's default user interface is based on direct manipulation, using touch inputs, that loosely correspond to real-world actions, like swiping, tapping, pinching, and reverse pinching to manipulate on-screen objects, and a virtual keyboard. The response to user input is designed to be immediate and provides a fluid touch interface, often using the vibration capabilities of the device to provide haptic feedback to the user. Internal hardware such as accelerometers, gyroscopes and proximity sensors are used by some applications to respond to additional user actions, for example adjusting the screen from portrait to landscape depending on how the device is oriented, or allowing the user to steer a vehicle in a racing game by rotating the device, simulating control of a steering wheel. Android devices boot to the homescreen, the primary navigation and information point on the device, which is similar to the desktop found on PCs. Android homescreens are typically made up of app icons and widgets; app icons launch the associated app, whereas widgets display live, auto-updating content such as the weather forecast, the user's email inbox, or a news ticker directly on the homescreen. A homescreen may be made up of several pages that the user can swipe back and forth between, though Android's homescreen interface is heavily customisable, allowing the user to adjust the look and feel of the device to their tastes. Third-party apps available on Google Play and other app stores can extensively re-theme the homescreen, and even mimic the look of other operating systems, such as Windows Phone. Most manufacturers, and some wireless carriers, customise the look and feel of their Android devices to differentiate themselves from their competitors.Present along the top of the screen is a status bar, showing information about the device and its connectivity. This status bar can be "pulled" down to reveal a notification screen where apps display important information or updates, such as a newly received email or SMS text, in a way that does not immediately interrupt or inconvenience the user. Notifications are persistent until read (by tapping, which opens the relevant app) or dismissed by sliding it off the screen. Beginning on Android 4.1, "expanded notifications" can display expanded details or additional functionality; for instance, a music player can display playback controls, and a "missed call" notification provides buttons for calling back or sending the caller an SMS message.
Android provides the ability to run applications which change the default launcher and hence the appearance and externally visible behaviour of Android. These appearance changes include a multi-page dock or no dock, and many more changes to fundamental features of the user interface.

Applications

See also: Android software development and Google Play
Android has a growing selection of third party applications, which can be acquired by users either through an app store such as Google Play or the Amazon Appstore, or by downloading and installing the application's APK file from a third-party site. Google Play Store allows users to browse, download and update applications published by Google and third-party developers, and the Play Store client application is pre-installed on devices that comply with Google's compatibility requirements and license the Google Mobile Services software. The client application filters the list of available applications down to those compatible with the user's device, and developers may restrict their applications to particular carriers or countries for business reasons. Purchases of unwanted applications can be refunded within 15 minutes of the time of download, and some carriers offer direct carrier billing for Google Play application purchases, where the cost of the application is added to the user's monthly bill.
As of July 2013, there are more than one million applications available for Android in Play Store. As of May 2013, 48 billion apps have been installed from Google Play store.
Applications ("apps"), that extend the functionality of devices, are developed primarily in the Java programming language language using the Android software development kit (SDK). The SDK includes a comprehensive set of development tools, including a debugger, software libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials. The officially supported integrated development environment (IDE) is Eclipse using the Android Development Tools (ADT) plugin. Other development tools are available, including a Native Development Kit for applications or extensions in C or C++, Google App Inventor, a visual environment for novice programmers, and various cross platform mobile web applications frameworks.
It was announced in January 2014 that Chrome HTML5 web applications should become available, using a compatibility layer from the open source Apache Cordova framework to allow such applications to be wrapped in a native application shell, enabling their distribution over Google Play.

 

Memory management

Since Android devices are usually battery-powered, Android is designed to manage memory (RAM) to keep power consumption at a minimum, in contrast to desktop operating systems which generally assume they are connected to unlimited mains electricity. When an Android app is no longer in use, the system will automatically suspend it in memory – while the app is still technically "open", suspended apps consume no resources (for example, battery power or processing power) and sit idly in the background until needed again. This has the dual benefit of increasing the general responsiveness of Android devices, since applications do not need to be closed and reopened from scratch each time, and also ensuring that background applications do not consume power needlessly.
Android manages the apps stored in memory automatically: when memory is low, the system will begin killing apps and processes that have been inactive for a while, in reverse order since they were last used (oldest first). This process is designed to be invisible to the user, such that users do not need to manage memory or the killing of apps themselves. However, confusion over Android memory management has resulted in third-party task killers becoming popular on Google Play store; these third-party task killers are generally regarded as doing more harm than good.

Android Platforms

Platform usage

The table below provides a breakdown of Android versions. This is based on devices accessing Play Store as of May 1, 2014, and therefore it excludes Android derivatives that do not access Google Play (for example, Kindle Fire).
Version Code name Release date API level Distribution
4.4 KitKat October 31, 2013 19 8.5%
4.3.x Jelly Bean July 24, 2013 18 8.5%
4.2.x November 13, 2012 17 18.8%
4.1.x July 9, 2012 16 33.5%
4.0.3–4.0.4 Ice Cream Sandwich December 16, 2011 15 13.4%
3.2 Honeycomb July 15, 2011 13 0.1%
2.3.3–2.3.7 Gingerbread February 9, 2011 10 16.2%
2.2 Froyo May 20, 2010 8 1.0%