SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Android Developers – Winners
Google’s Android mobile phone software platform is the next big opportunity for application software developers.

With the existing mobile development build on proprietary operating systems that restrict the development and
deployment of third-party applications, Android offers an open alternative. Android developers are free to write
applications that enjoys full advantage of powerful mobile hardware and distribute them in an open market.

Built on an open source framework, and featuring powerful SDK libraries and a much open philosophy, Android has
opened mobile phone development to thousands of developers who haven’t had access to tools for building mobile
applications. Experienced mobile developers can now expand into the Android platform, leveraging the unique
features to enhance existing products or create innovative ones.

Using the Android Market for distribution, developers can take advantage of an open marketplace, with no review
process, for distributing free and paid apps to all compatible Android devices.



What are the problems that Android improves?
Fragmentation: Till now there are a lot of phones available which can run applications, but each brand has a
different application environment. This is mostly true in case of Linux based phones, where each handset vendor has
had to assemble plenty of pieces of third-party software to create a viable mobile phone platform. Java was
supposed to help this situation. Unfortunately, almost every handset that supports J2ME also supports vendor-
proprietary extensions that limit the portability of applications.

Proprietary Software Stacks: Most existing smartphones such as Nokia’s Series 60 with Symbian OS, or Microsoft’s
Windows Mobile use proprietary & relatively closed software stacks. Modifications to these stacks (example - adding
a device driver) have to be done either by the stack owner or by the handset manufacturer. The stacks are not open
source, so changing anything in the stack is difficult. Most Linux-based phones to date have an open source kernel,
but keep other details of the software stack (application framework, multimedia framework, applications)
proprietary.

Closed Networks: Mobile operators often lock the handsets so applications cannot be added. The operators claim
this is needed to preserve the integrity of their mobile networks. It also suits the operator’s business model. Android
includes an open catalog of applications, Android Market, which users can download over the air to their Android
phones. It also allows direct loading of applications via USB connection.

Android gives developers a way to develop unique, creative applications and get those applications in the hands of
customers.




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                      Page 1
Component LifeCycle




                                  Component Services




                           Component – Content Providers




                              Producing an Android App




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support   Page 2
Resources Types:




    Animation Resources (/anim or /drawable)

    Color State List Resource (/color)

    Drawable Resources(/drawable)

    Layout Resource(/layout)

    Menu Resource(/menu)

    String Resources(/values)

    Style Resource(/values)

    More Resource Types(/values)




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support   Page 3
Screen Characteristic

Screen characteristic   Qualifier        Description


                        small            Resources for small size screens.


                        normal           Resources for normal size screens. (This is the baseline size.)
Size
                        large            Resources for large size screens.


                        xlarge           Resources for extra large size screens.


                        ldpi             Resources for low-density (ldpi) screens (~120dpi).


                                         Resources for medium-density (mdpi) screens (~160dpi).
                        mdpi
                                         (This is the baseline density.)


                        hdpi             Resources for high-density (hdpi) screens (~240dpi).


                        xhdpi            Resources for extra high-density (xhdpi) screens (~320dpi).
Density

                                         Resources for all densities. These are density-independent
                        nodpi            resources. The system does not scale resources tagged with
                                         this qualifier, regardless of the current screen's density.


                                         Resources for screens somewhere between mdpi and hdpi;
                        tvdpi            approximately 213dpi. This is not considered a "primary"
                                         density group.


                                         Resources for screens in the landscape orientation (wide
                        land
                                         aspect ratio).
Orientation
                                         Resources for screens in the portrait orientation (tall aspect
                        port
                                         ratio).


                                         Resources for screens that have a significantly taller or wider
                        long             aspect ratio (when in portrait or landscape orientation,
                                         respectively) than the baseline screen configuration.
Aspect ratio

                                         Resources for use screens that have an aspect ratio that is
                        notlong
                                         similar to the baseline screen configuration.




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                             Page 4
Components of an Android Application
Activities: Activities are pieces of executable code that come and go in time, instantiated by either the user or the
operating system and running as long as they are needed. They can interact with the user and request data or
services from other activities or services via queries or Intents.

Services: They are executable pieces of code that usually run in the background from the time of their instantiation
until the mobile handset is shut down. They generally don’t expose a user interface.

Broadcast and Intent Receivers: These respond to requests for service from another application. A Broadcast
Receiver Broadcast Receiver responds to a system-wide announcement of an event. These announcements can come
from Android itself (e.g., battery low) or from any program running on the system. An Activity or Service provides
other applications with access to its functionality by executing an Intent Receiver, a small piece of executable code
that responds to requests for data or services from other activities.

Content Providers: These are created to share data with other activities or services. A content provider uses a
standard interface in the form of a URI to fulfil requests for data from other applications that may not even know
which content provider they are using.



Android Activity Lifecycle
The mechanisms are evident in the Android Activity Lifecycle, which defines the states or events that an activity goes
through from the time it is created until it finishes running.

To understand these concepts, you should Google about:

onCreate, onStart, onResume, onPause, onStop and onDestroy

It is important to take advantage of these methods to provide the best user experience possible.




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                     Page 5
Hello, World
    As a developer, you know that the first impression of a development framework is how easy it is to write "Hello,
    World." Well, on Android, it's pretty easy. It's particularly easy if you're using Eclipse as your IDE, because we've
    provided a great plugin that handles your project creation and management to greatly speed-up your development
    cycles.



    Install a Platform

    To run the Hello World application, you need to install at least one Android platform in your SDK environment. If you
    have not already performed this step, you need to do it now. To install a platform in Eclipse:

1. In the Android SDK and AVD Manager, choose           Available Packages in the left panel.
2. Click the repository site checkbox to display the components available for installation.
3. Select at least one platform to install, and click   Install Selected. If you aren't sure which platform to install, use the
    latest version.



    Create an AVD

    In this tutorial, you will run your application in the Android Emulator. Before you can launch the emulator, you must
    create an Android Virtual Device (AVD). An AVD defines the system image and device settings used by the emulator.
    To create an AVD:

1. In Eclipse, choose Window       > Android SDK and AVD Manager.
2. Select VirtualDevices in the left panel.
3. Click New. The Create New AVD dialog appears.
4. Type the name of the AVD, such as "my_avd".
5. Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.1) you want to run on
    the emulator.
    You can ignore the rest of the fields for now.

6. Click Create       AVD.


    Create a New Android Project

    After you've created an AVD, the next step is to start a new Android project in Eclipse.

1. From Eclipse, select   File > New > Project.
    If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled
    "Android" which should contain "Android Project". (After you create one or more Android projects, an entry for
    "Android XML File" will also be available.)
2. Select "Android Project" and click   Next.




    Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                          Page 6
3. Fill in the project details with the following values:
o   Project name: HelloAndroid
o   Application name: Hello, Android
o   Package name: com.example.helloandroid (or your
    own private namespace)
o   Create Activity: HelloAndroid

    Click Finish.




    Here is a description of each field:
    Project Name
             This is the Eclipse Project name — the name of the
             directory that will contain the project files.

    Application Name
             This is the human-readable title for your application — the
             name that will appear on the Android device.

    Package Name
             This is the package namespace (following the same rules
             as for packages in the Java programming language) that
             you want all your source code to reside under. This also
             sets the package name under which the stub Activity will
             be generated.

             Your package name must be unique across all packages
             installed on the Android system; for this reason, it's
             important to use a standard domain-style package for your
             applications. The example above uses the "com.example"
             namespace, which is a namespace reserved for example
             documentation      —     when     you    develop   your    own
             applications,   you    should    use    a   namespace     that's
             appropriate to your organization or entity.
    Create Activity
             This is the name for the class stub that will be generated by the plugin. This will be a subclass of
             Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it

    Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                  Page 7
chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an Activity is almost always
        used as the basis for an application.

Min SDK Version
        This value specifies the minimum API Level required by your application.

Other fields: The checkbox for "Use default location" allows you to change the location on disk where the project's files
will be generated and stored. "Build Target" is the platform target that your application will be compiled against (this
should be selected automatically, based on your Min SDK Version).

Notice that the "Build Target" you've selected uses the Android 1.1 platform. This means that your application will be
compiled against the Android 1.1 platform library. If you recall, the AVD created above runs on the Android 1.5
platform. These don't have to match; Android applications are forward-compatible, so an application built against the
1.1 platform library will run normally on the 1.5 platform. The reverse is not true.
Your Android project is now ready. It should be visible in the Package Explorer on the left. Open
the HelloAndroid.java file, located inside HelloAndroid > src > com.example.helloandroid). It should look like this:


  package com.example.helloandroid;

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

  public class HelloAndroid extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  }


Notice that the class is based on the Activity class. An Activity is a single application entity that is used to perform
actions. An application may have many separate activities, but the user interacts with them one at a time.
The onCreate() method will be called by the Android system when your Activity starts — it is where you should
perform all initialization and UI setup. An activity is not required to have a user interface, but usually will.

Now let's modify some code!



Construct the UI
Take a look at the revised code below and then make the same changes to your HelloAndroid class. The bold items
are lines that have been added.




  package com.example.helloandroid;

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

  public class HelloAndroid extends Activity {


Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                           Page 8
/** Called when the activity is first created. */
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              TextView tv = new TextView(this);
              tv.setText("Hello, Android");
              setContentView(tv);
          }
      }


   An Android user interface is composed of hierarchies of objects called Views. A View is a drawable object used as an
   element in your UI layout, such as a button, image, or (in this case) a text label. Each of these objects is a subclass of
   the View class and the subclass that handles text is TextView.

   In this change, you create a TextView with the class constructor, which accepts an Android Context instance as its
   parameter. A Context is a handle to the system; it provides services like resolving resources, obtaining access to
   databases and preferences, and so on. The Activity class inherits from Context, and because your HelloAndroid class
   is a subclass of Activity, it is also a Context. So, you can pass this as your Context reference to the TextView.

   Next, you define the text content with setText(). Finally, you pass the TextView to setContentView() in order to
   display it as the content for the Activity UI. If your Activity doesn't call this method, then no UI is present and the
   system will display a blank screen. There it is — "Hello, World" in Android! The next step, of course, is to see it
   running.



   Run the Application

   The Eclipse plugin makes it easy to run your applications:

1. Select Run    > Run.
2. Select "Android Application".
   The Eclipse plugin automatically creates a new run configuration for your project and then launches the Android
   Emulator. Depending on your environment, the Android emulator might take
   several minutes to boot fully, so please be patient. You should now see
   something like this:

   The "Hello, Android" you see in the grey bar is actually the application title. The
   Eclipse    plugin   creates   this   automatically    (the   string   is   defined   in
   the res/values/strings.xml file                 and            referenced            by
   your AndroidManifest.xml file). The text below the title is the actual text that
   you have created in the TextView object.

   That concludes the basic "Hello World" tutorial, but you should continue reading
   for some more valuable information about developing Android applications.




   Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support                                        Page 9
NOTES
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________




Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support   Page 10

Contenu connexe

Plus de NAILBITER

Cloud Workshop - Presentation
Cloud Workshop - PresentationCloud Workshop - Presentation
Cloud Workshop - PresentationNAILBITER
 
Android Fundamentals & Figures of 2012
Android Fundamentals & Figures of 2012Android Fundamentals & Figures of 2012
Android Fundamentals & Figures of 2012NAILBITER
 
The iPhone development on windows
The iPhone development on windowsThe iPhone development on windows
The iPhone development on windowsNAILBITER
 
Ambastha EduTech Pvt Ltd
Ambastha EduTech Pvt LtdAmbastha EduTech Pvt Ltd
Ambastha EduTech Pvt LtdNAILBITER
 
Develop open source search engine
Develop open source search engineDevelop open source search engine
Develop open source search engineNAILBITER
 
Location based solutions maps & your location
Location based solutions   maps & your locationLocation based solutions   maps & your location
Location based solutions maps & your locationNAILBITER
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1NAILBITER
 
Android Workshop - Session 2
Android Workshop - Session 2Android Workshop - Session 2
Android Workshop - Session 2NAILBITER
 
Linux Seminar for Beginners
Linux Seminar for BeginnersLinux Seminar for Beginners
Linux Seminar for BeginnersNAILBITER
 
Linux advanced concepts - Part 2
Linux advanced concepts - Part 2Linux advanced concepts - Part 2
Linux advanced concepts - Part 2NAILBITER
 
Linux advanced concepts - Part 1
Linux advanced concepts - Part 1Linux advanced concepts - Part 1
Linux advanced concepts - Part 1NAILBITER
 
Linux concepts
Linux conceptsLinux concepts
Linux conceptsNAILBITER
 
Linux basics
Linux basicsLinux basics
Linux basicsNAILBITER
 
Career-Edge Magazine coverage - Ritesh Ambastha
Career-Edge Magazine coverage  - Ritesh AmbasthaCareer-Edge Magazine coverage  - Ritesh Ambastha
Career-Edge Magazine coverage - Ritesh AmbasthaNAILBITER
 
Ubuntu Workshop Kit - Study Material
Ubuntu Workshop Kit - Study MaterialUbuntu Workshop Kit - Study Material
Ubuntu Workshop Kit - Study MaterialNAILBITER
 
Android Workshop Presentation
Android Workshop PresentationAndroid Workshop Presentation
Android Workshop PresentationNAILBITER
 
Social media part 1
Social media part 1Social media part 1
Social media part 1NAILBITER
 
Social media part 2
Social media part 2Social media part 2
Social media part 2NAILBITER
 

Plus de NAILBITER (20)

Cloud Workshop - Presentation
Cloud Workshop - PresentationCloud Workshop - Presentation
Cloud Workshop - Presentation
 
Android Fundamentals & Figures of 2012
Android Fundamentals & Figures of 2012Android Fundamentals & Figures of 2012
Android Fundamentals & Figures of 2012
 
The iPhone development on windows
The iPhone development on windowsThe iPhone development on windows
The iPhone development on windows
 
Ambastha EduTech Pvt Ltd
Ambastha EduTech Pvt LtdAmbastha EduTech Pvt Ltd
Ambastha EduTech Pvt Ltd
 
Branding
BrandingBranding
Branding
 
Advertising
AdvertisingAdvertising
Advertising
 
Develop open source search engine
Develop open source search engineDevelop open source search engine
Develop open source search engine
 
Location based solutions maps & your location
Location based solutions   maps & your locationLocation based solutions   maps & your location
Location based solutions maps & your location
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1
 
Android Workshop - Session 2
Android Workshop - Session 2Android Workshop - Session 2
Android Workshop - Session 2
 
Linux Seminar for Beginners
Linux Seminar for BeginnersLinux Seminar for Beginners
Linux Seminar for Beginners
 
Linux advanced concepts - Part 2
Linux advanced concepts - Part 2Linux advanced concepts - Part 2
Linux advanced concepts - Part 2
 
Linux advanced concepts - Part 1
Linux advanced concepts - Part 1Linux advanced concepts - Part 1
Linux advanced concepts - Part 1
 
Linux concepts
Linux conceptsLinux concepts
Linux concepts
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Career-Edge Magazine coverage - Ritesh Ambastha
Career-Edge Magazine coverage  - Ritesh AmbasthaCareer-Edge Magazine coverage  - Ritesh Ambastha
Career-Edge Magazine coverage - Ritesh Ambastha
 
Ubuntu Workshop Kit - Study Material
Ubuntu Workshop Kit - Study MaterialUbuntu Workshop Kit - Study Material
Ubuntu Workshop Kit - Study Material
 
Android Workshop Presentation
Android Workshop PresentationAndroid Workshop Presentation
Android Workshop Presentation
 
Social media part 1
Social media part 1Social media part 1
Social media part 1
 
Social media part 2
Social media part 2Social media part 2
Social media part 2
 

Dernier

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Dernier (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Android workshop handout

  • 1. Android Developers – Winners Google’s Android mobile phone software platform is the next big opportunity for application software developers. With the existing mobile development build on proprietary operating systems that restrict the development and deployment of third-party applications, Android offers an open alternative. Android developers are free to write applications that enjoys full advantage of powerful mobile hardware and distribute them in an open market. Built on an open source framework, and featuring powerful SDK libraries and a much open philosophy, Android has opened mobile phone development to thousands of developers who haven’t had access to tools for building mobile applications. Experienced mobile developers can now expand into the Android platform, leveraging the unique features to enhance existing products or create innovative ones. Using the Android Market for distribution, developers can take advantage of an open marketplace, with no review process, for distributing free and paid apps to all compatible Android devices. What are the problems that Android improves? Fragmentation: Till now there are a lot of phones available which can run applications, but each brand has a different application environment. This is mostly true in case of Linux based phones, where each handset vendor has had to assemble plenty of pieces of third-party software to create a viable mobile phone platform. Java was supposed to help this situation. Unfortunately, almost every handset that supports J2ME also supports vendor- proprietary extensions that limit the portability of applications. Proprietary Software Stacks: Most existing smartphones such as Nokia’s Series 60 with Symbian OS, or Microsoft’s Windows Mobile use proprietary & relatively closed software stacks. Modifications to these stacks (example - adding a device driver) have to be done either by the stack owner or by the handset manufacturer. The stacks are not open source, so changing anything in the stack is difficult. Most Linux-based phones to date have an open source kernel, but keep other details of the software stack (application framework, multimedia framework, applications) proprietary. Closed Networks: Mobile operators often lock the handsets so applications cannot be added. The operators claim this is needed to preserve the integrity of their mobile networks. It also suits the operator’s business model. Android includes an open catalog of applications, Android Market, which users can download over the air to their Android phones. It also allows direct loading of applications via USB connection. Android gives developers a way to develop unique, creative applications and get those applications in the hands of customers. Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 1
  • 2. Component LifeCycle Component Services Component – Content Providers Producing an Android App Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 2
  • 3. Resources Types:  Animation Resources (/anim or /drawable)  Color State List Resource (/color)  Drawable Resources(/drawable)  Layout Resource(/layout)  Menu Resource(/menu)  String Resources(/values)  Style Resource(/values)  More Resource Types(/values) Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 3
  • 4. Screen Characteristic Screen characteristic Qualifier Description small Resources for small size screens. normal Resources for normal size screens. (This is the baseline size.) Size large Resources for large size screens. xlarge Resources for extra large size screens. ldpi Resources for low-density (ldpi) screens (~120dpi). Resources for medium-density (mdpi) screens (~160dpi). mdpi (This is the baseline density.) hdpi Resources for high-density (hdpi) screens (~240dpi). xhdpi Resources for extra high-density (xhdpi) screens (~320dpi). Density Resources for all densities. These are density-independent nodpi resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density. Resources for screens somewhere between mdpi and hdpi; tvdpi approximately 213dpi. This is not considered a "primary" density group. Resources for screens in the landscape orientation (wide land aspect ratio). Orientation Resources for screens in the portrait orientation (tall aspect port ratio). Resources for screens that have a significantly taller or wider long aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration. Aspect ratio Resources for use screens that have an aspect ratio that is notlong similar to the baseline screen configuration. Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 4
  • 5. Components of an Android Application Activities: Activities are pieces of executable code that come and go in time, instantiated by either the user or the operating system and running as long as they are needed. They can interact with the user and request data or services from other activities or services via queries or Intents. Services: They are executable pieces of code that usually run in the background from the time of their instantiation until the mobile handset is shut down. They generally don’t expose a user interface. Broadcast and Intent Receivers: These respond to requests for service from another application. A Broadcast Receiver Broadcast Receiver responds to a system-wide announcement of an event. These announcements can come from Android itself (e.g., battery low) or from any program running on the system. An Activity or Service provides other applications with access to its functionality by executing an Intent Receiver, a small piece of executable code that responds to requests for data or services from other activities. Content Providers: These are created to share data with other activities or services. A content provider uses a standard interface in the form of a URI to fulfil requests for data from other applications that may not even know which content provider they are using. Android Activity Lifecycle The mechanisms are evident in the Android Activity Lifecycle, which defines the states or events that an activity goes through from the time it is created until it finishes running. To understand these concepts, you should Google about: onCreate, onStart, onResume, onPause, onStop and onDestroy It is important to take advantage of these methods to provide the best user experience possible. Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 5
  • 6. Hello, World As a developer, you know that the first impression of a development framework is how easy it is to write "Hello, World." Well, on Android, it's pretty easy. It's particularly easy if you're using Eclipse as your IDE, because we've provided a great plugin that handles your project creation and management to greatly speed-up your development cycles. Install a Platform To run the Hello World application, you need to install at least one Android platform in your SDK environment. If you have not already performed this step, you need to do it now. To install a platform in Eclipse: 1. In the Android SDK and AVD Manager, choose Available Packages in the left panel. 2. Click the repository site checkbox to display the components available for installation. 3. Select at least one platform to install, and click Install Selected. If you aren't sure which platform to install, use the latest version. Create an AVD In this tutorial, you will run your application in the Android Emulator. Before you can launch the emulator, you must create an Android Virtual Device (AVD). An AVD defines the system image and device settings used by the emulator. To create an AVD: 1. In Eclipse, choose Window > Android SDK and AVD Manager. 2. Select VirtualDevices in the left panel. 3. Click New. The Create New AVD dialog appears. 4. Type the name of the AVD, such as "my_avd". 5. Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.1) you want to run on the emulator. You can ignore the rest of the fields for now. 6. Click Create AVD. Create a New Android Project After you've created an AVD, the next step is to start a new Android project in Eclipse. 1. From Eclipse, select File > New > Project. If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Android" which should contain "Android Project". (After you create one or more Android projects, an entry for "Android XML File" will also be available.) 2. Select "Android Project" and click Next. Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 6
  • 7. 3. Fill in the project details with the following values: o Project name: HelloAndroid o Application name: Hello, Android o Package name: com.example.helloandroid (or your own private namespace) o Create Activity: HelloAndroid Click Finish. Here is a description of each field: Project Name This is the Eclipse Project name — the name of the directory that will contain the project files. Application Name This is the human-readable title for your application — the name that will appear on the Android device. Package Name This is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. This also sets the package name under which the stub Activity will be generated. Your package name must be unique across all packages installed on the Android system; for this reason, it's important to use a standard domain-style package for your applications. The example above uses the "com.example" namespace, which is a namespace reserved for example documentation — when you develop your own applications, you should use a namespace that's appropriate to your organization or entity. Create Activity This is the name for the class stub that will be generated by the plugin. This will be a subclass of Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 7
  • 8. chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application. Min SDK Version This value specifies the minimum API Level required by your application. Other fields: The checkbox for "Use default location" allows you to change the location on disk where the project's files will be generated and stored. "Build Target" is the platform target that your application will be compiled against (this should be selected automatically, based on your Min SDK Version). Notice that the "Build Target" you've selected uses the Android 1.1 platform. This means that your application will be compiled against the Android 1.1 platform library. If you recall, the AVD created above runs on the Android 1.5 platform. These don't have to match; Android applications are forward-compatible, so an application built against the 1.1 platform library will run normally on the 1.5 platform. The reverse is not true. Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.java file, located inside HelloAndroid > src > com.example.helloandroid). It should look like this: package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } Notice that the class is based on the Activity class. An Activity is a single application entity that is used to perform actions. An application may have many separate activities, but the user interacts with them one at a time. The onCreate() method will be called by the Android system when your Activity starts — it is where you should perform all initialization and UI setup. An activity is not required to have a user interface, but usually will. Now let's modify some code! Construct the UI Take a look at the revised code below and then make the same changes to your HelloAndroid class. The bold items are lines that have been added. package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity { Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 8
  • 9. /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); } } An Android user interface is composed of hierarchies of objects called Views. A View is a drawable object used as an element in your UI layout, such as a button, image, or (in this case) a text label. Each of these objects is a subclass of the View class and the subclass that handles text is TextView. In this change, you create a TextView with the class constructor, which accepts an Android Context instance as its parameter. A Context is a handle to the system; it provides services like resolving resources, obtaining access to databases and preferences, and so on. The Activity class inherits from Context, and because your HelloAndroid class is a subclass of Activity, it is also a Context. So, you can pass this as your Context reference to the TextView. Next, you define the text content with setText(). Finally, you pass the TextView to setContentView() in order to display it as the content for the Activity UI. If your Activity doesn't call this method, then no UI is present and the system will display a blank screen. There it is — "Hello, World" in Android! The next step, of course, is to see it running. Run the Application The Eclipse plugin makes it easy to run your applications: 1. Select Run > Run. 2. Select "Android Application". The Eclipse plugin automatically creates a new run configuration for your project and then launches the Android Emulator. Depending on your environment, the Android emulator might take several minutes to boot fully, so please be patient. You should now see something like this: The "Hello, Android" you see in the grey bar is actually the application title. The Eclipse plugin creates this automatically (the string is defined in the res/values/strings.xml file and referenced by your AndroidManifest.xml file). The text below the title is the actual text that you have created in the TextView object. That concludes the basic "Hello World" tutorial, but you should continue reading for some more valuable information about developing Android applications. Questions? Visit www.iwillstudy.com/group/android/ for 24x7 Free Support Page 9