SlideShare a Scribd company logo
1 of 9
The Greenoid’s GuideTo Building  Android™ Apps [Part–2/6] Android & the Green Robot  are a trademark of Google Inc. http://greenoid.blogspot.com (Oct 2010)
The App Innards http://greenoid.blogspot.com (Oct 2010)
What Goes into an App? Activities Each activity is an Android version of a basic UI block Content Provider You write content providers  to share data of any form residing on the device with other applications Services If you want your code to run always, without any UI elements, services are the answer Intents A notification mechanism for system events like hardware changes, incoming sms … you can also create your own intents to notify others. http://greenoid.blogspot.com (Oct 2010)
Inside An Android Project The Manifest File A declaration of all components inside your application, like activities, services, user permissions, SDK version, and optional libraries in use. XML Layouts You can specify an UI layout in XML and attach it to an activity, giving you freedom to modify the UI without worrying about code. R.java An auto-generated file that connects resources like the XML layout definitions to java code. http://greenoid.blogspot.com (Oct 2010)
Writing an App Thankfully  when you click on New Project in Eclipse the basic skeleton and Manifest file are auto-magically created. The skeleton public class MyActivityextends Activity { @Override     public void onCreate(Bundle icicle) { super.onCreate(icicle); TextViewtv = new TextView(this); setContentView(tv); } } http://greenoid.blogspot.com (Oct 2010)
The Skeleton Explained MyActivity  extends  Activity  Think of the Activity like a high level UI container Public  void  onCreate(Bundle icicle)  Invoked when the activity is created, you might want to create some basic UI widget like a button or TextView here setContentView( TextView ) Since the Activity is a high-level UI container, you will have to call setContentView(button/label) to add your widget to the container If you created a button You will have to do btn.setOnClickListener() to receive events And implement public void onClick(View v) to handle it http://greenoid.blogspot.com (Oct 2010)
The Widget Palette All Widgets extend View TextView - A basic label widget Button - Well, it’s a button ImageView, ImageButton: support for images CheckBox, RadioButton, RadioGroupare a few common UI widgets http://greenoid.blogspot.com (Oct 2010)
Sample Code For the Lazy package com.droid.clockwork; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import java.util.Date; public class MainClock extends Activity { /** Called when the activity is first created. */   public void onCreate(Bundle icicle) { super.onCreate(icicle); TextViewtv = new TextView(this); tv.setText("The Time Now Is: "+new Date().toString()); setContentView(tv);     } } http://greenoid.blogspot.com (Oct 2010)
Coming soon Part 3/6 http://greenoid.blogspot.com (Oct 2010) Meanwhile checkout our blog: http://greenoid.blogspot.com

More Related Content

Similar to Learning Android Part 2/6

Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Amit Saxena
 
Android Homescreen Widgets Demystified
Android Homescreen Widgets DemystifiedAndroid Homescreen Widgets Demystified
Android Homescreen Widgets DemystifiedPearl Chen
 
Get an Android tutorial for beginners
Get an Android tutorial for beginnersGet an Android tutorial for beginners
Get an Android tutorial for beginnersJavaTpoint.Com
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docPalakjaiswal43
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidjavalabsf
 

Similar to Learning Android Part 2/6 (20)

Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
Android Homescreen Widgets Demystified
Android Homescreen Widgets DemystifiedAndroid Homescreen Widgets Demystified
Android Homescreen Widgets Demystified
 
Get an Android tutorial for beginners
Get an Android tutorial for beginnersGet an Android tutorial for beginners
Get an Android tutorial for beginners
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Google Android
Google AndroidGoogle Android
Google Android
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android
AndroidAndroid
Android
 
Android
AndroidAndroid
Android
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Learning Android Part 2/6

  • 1. The Greenoid’s GuideTo Building Android™ Apps [Part–2/6] Android & the Green Robot are a trademark of Google Inc. http://greenoid.blogspot.com (Oct 2010)
  • 2. The App Innards http://greenoid.blogspot.com (Oct 2010)
  • 3. What Goes into an App? Activities Each activity is an Android version of a basic UI block Content Provider You write content providers to share data of any form residing on the device with other applications Services If you want your code to run always, without any UI elements, services are the answer Intents A notification mechanism for system events like hardware changes, incoming sms … you can also create your own intents to notify others. http://greenoid.blogspot.com (Oct 2010)
  • 4. Inside An Android Project The Manifest File A declaration of all components inside your application, like activities, services, user permissions, SDK version, and optional libraries in use. XML Layouts You can specify an UI layout in XML and attach it to an activity, giving you freedom to modify the UI without worrying about code. R.java An auto-generated file that connects resources like the XML layout definitions to java code. http://greenoid.blogspot.com (Oct 2010)
  • 5. Writing an App Thankfully when you click on New Project in Eclipse the basic skeleton and Manifest file are auto-magically created. The skeleton public class MyActivityextends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); TextViewtv = new TextView(this); setContentView(tv); } } http://greenoid.blogspot.com (Oct 2010)
  • 6. The Skeleton Explained MyActivity extends Activity Think of the Activity like a high level UI container Public void onCreate(Bundle icicle) Invoked when the activity is created, you might want to create some basic UI widget like a button or TextView here setContentView( TextView ) Since the Activity is a high-level UI container, you will have to call setContentView(button/label) to add your widget to the container If you created a button You will have to do btn.setOnClickListener() to receive events And implement public void onClick(View v) to handle it http://greenoid.blogspot.com (Oct 2010)
  • 7. The Widget Palette All Widgets extend View TextView - A basic label widget Button - Well, it’s a button ImageView, ImageButton: support for images CheckBox, RadioButton, RadioGroupare a few common UI widgets http://greenoid.blogspot.com (Oct 2010)
  • 8. Sample Code For the Lazy package com.droid.clockwork; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import java.util.Date; public class MainClock extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle icicle) { super.onCreate(icicle); TextViewtv = new TextView(this); tv.setText("The Time Now Is: "+new Date().toString()); setContentView(tv); } } http://greenoid.blogspot.com (Oct 2010)
  • 9. Coming soon Part 3/6 http://greenoid.blogspot.com (Oct 2010) Meanwhile checkout our blog: http://greenoid.blogspot.com