SlideShare a Scribd company logo
Android GUI Project
John Hurley
CS 454
Android
• 1. Android Basics
• 2. Android Development
• 3. Android UI
• 4. Hello, World
• 5. My Project
Android Basics
• Open source OS
• Uses Linux kernel
• Optimized for limited-resource environment
• Apps typically written in Java
• Apps run on the Dalvik Virtual Machine
• Not a JVM, but works similarly from developer’s point
of view
• Usually one app per DVM
• Each DVM runs under Linux as a separate user
• App permissions set at install time
• Possible to use C or C++ compiled to machine code, but still
runs on VM. It’s not clear to me how this works.
• Docs say it does not necessarily improve performance.
Sams Teach Yourself Android™Application Development in 24 Hours (0321673352)
Copyright ©2010 Lauren Darcey and Shane Conder
FIGURE 5.6 Simplified Android platform architecture from a security perspective.
Android Development
• Well-defined framework for app development
• Apps are typically coded using Java syntax, but
other parts of the Java platform are missing
• Some standard Java SE or ME APIs and class
libraries are not included
• I will give examples when I find out!
Android Development
• Standard development environment is Eclipse + Android
Development Tools plugin + Android SDK
• Development requires either an Android OS device or an
emulator
• Emulator has limitations:
• Performance is poor
• Camera, etc., simulated using your computer’s hardware
• No real phone calls or texts
• GPS data, battery readings, etc. must be simulated
• Real device is affected by specific hardware and software
configuration
OS
I was able to choose what kind of smart phone to get according
to which platform I wanted to use to try mobile development
Android:
•I had Java backend code ready to go for a first project
•Interesting platform:
• Familiar programming environment
• Currently the market leader
• Broad market, unlike more focused iOS, Blackberry, and
(Palm) webOS
• Development tools are open source and are free even for
commercial use, unlike Visual Studio
Android App vs. Mobile- Optimized RIA
• Android Flash plugins available; Silverlight coming soon
• Could develop in JavaScript and/or HTML5
• WWW App
• Easier for users to run; no need to install
• For a paid app, avoid the 30% App Store commission
• Easier to write cross-platform apps
• Android Apps
• Fewer security hurdles
• Use APIs for access to built in GPS, camera, etc.
• Probably better performance; one layer less
Android Apps: Marketing
• Usually market apps through Android App Market
• There are other markets, also
• App store will dominate the market due to access through
built in app
• Can set up for download directly on a website
• User must agree to “install apps from unknown sources”
Android Apps: Marketing
• Revenue from app sales prices and/or advertising
• Conventional wisdom is that iOS users will pay for apps,
but Android users won’t
• 57% of Android App Store apps are free, vs. 28% for Apple
App Store
• Android Market takes 30% commission
• Any purchase model other than one-time purchase must be
homegrown, using Paypal or similar service
• PPC ads
• My guess is that response to these is extremely low
• Probably need to be very aggressive with banner ads
• Sell to companies?
Android Deployment
• Apps are packaged in .apk format, variant of .jar,
then downloaded to device and installed
• .apks contain .dex files (bytecode), manifest and
various other files
• Manifest contains security and link info,
hardware access info, minimum OS release info,
etc.
Android UI
• Activity: single screen with a UI, somewhat analogous to
XAML / code behind pattern in .NET
• Email app might have one activity that shows a list of
new emails, another activity to compose an email, and
another activity for reading emails
• Implement by subclassing Activity class
• View: drawable object
• Android UI View ≠ MVC View
• UI contains a hierarchy of Views
• View is a class, subclassed by the drawable objects in
the UI
Android UI
• Service: background operation
• play music in the background while the user is in
a different application
• fetch data over the network without blocking
user interaction with an activity
• Content Provider: DB or other data access
• Broadcast Receiver: responds to system messages
• Battery low
Android UI
• UI construction can be done in three ways:
• Programmatic, like hand-coded Java desktop GUI
construction
• Declarative hand-written, like Java web UI
construction
• XML
• Declarative with a GUI builder, like .NET UI
construction
• GUI builder generates the XML
Programmatic UI
package cs454.demo;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class AndroidDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Activity is a subclass of context, so the TextView takes this as a parameter
TextView tv = new TextView(this);
tv.setText("Hello, CS454");
setContentView(tv);
}
}
Manual Declarative UI
main.xml Layout File:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
strings.xml resource file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello Again, CS454!</string>
<string name="app_name">CS454 AndroidDemo</string>
</resources>
Manual Declarative UI
Java class:
package cs454.demo;
import android.app.Activity;
import android.os.Bundle;
public class AndroidDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
What’s R?/* AUTO-GENERATED FILE. DO NOT MODIFY. This class was automatically generated by the
* aapt tool from the resource data it found. It should not be modified by hand. */
package cs454.demo;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int textview=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
UI With GUI Builder
Android Event Handlers
From the code file for the activity:
Button ok = (Button) findViewById(R.id.button1);
ok.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CharSequence s = et.getText();
tv.setText("Welcome, " + s);
}
});
Sams Teach Yourself Android™Application Development in 24 Hours (0321673352)
Copyright ©2010 Lauren Darcey and Shane Conder
FIGURE 3.2 Important callback methods of the activity life cycle.
APIs for Android built-ins
• Android OS ships with many built in apps
• Web Browser
• Google Maps
• Navigation
• Camera apps
• Built in access for these as well as TTS and Voice
Recognition, etc.
Demo
My Project
• Goats and Tigers is a board game, which we implemented in
Java in CS 460 last term.
• The objective in CS460 was to implement the minmax / alpha
beta pruning algorithm for the automatic player, not to
create a good UI
• My existing interface shows an ASCII art picture of the board
and provides a JOptionPane menu of available moves
• I will develop an Android UI and use my existing backend
code as much as possible
References
• http://www.ibm.com/developerworks/opensource/library/os-android-
devel/
• http://developer.android.com/resources/browser.html?tag=tutorial
• Conder and Darcey, Android Wireless Application Development, Addison-
Wesley, 2010
• Conder and Darcey, Sams Teach Yourself Android Application
Development in 24 Hours, Sams, 2010

More Related Content

What's hot

Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...
Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...
Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...Jason Conger
 
IONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App DevelopmentIONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App Development
Malan Amarasinghe
 
Android studio
Android studioAndroid studio
Android studio
Željko Plesac
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET Guy
Nick Landry
 
Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011
sullis
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Developing Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKDeveloping Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKNick Landry
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15
sullis
 
Creating an hybrid app in minutes with Ionic Framework
Creating an hybrid app in minutes with Ionic FrameworkCreating an hybrid app in minutes with Ionic Framework
Creating an hybrid app in minutes with Ionic Framework
Julien Renaux
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
Massimo Oliviero
 
Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021
Svetlin Nakov
 
Selenium training
Selenium trainingSelenium training
Selenium training
Shivaraj R
 
An overview of mobile html + java script frameworks
An overview of mobile html + java script frameworksAn overview of mobile html + java script frameworks
An overview of mobile html + java script frameworksSasha dos Santos
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio Overview
Salim Hosen
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
Bitbar
 
Introduction_to_android_and_android_studio
Introduction_to_android_and_android_studioIntroduction_to_android_and_android_studio
Introduction_to_android_and_android_studio
Abdul Basit
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011
sullis
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
Pasi Manninen
 
Introduction to the Ionic Framework
Introduction to the Ionic FrameworkIntroduction to the Ionic Framework
Introduction to the Ionic Framework
rrjohnson85
 
Role of java in android app development
Role of java in android app developmentRole of java in android app development
Role of java in android app development
Rahul Rana
 

What's hot (20)

Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...
Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...
Building your Own Mobile Enterprise Application: It’s Not as Hard as You Migh...
 
IONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App DevelopmentIONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App Development
 
Android studio
Android studioAndroid studio
Android studio
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET Guy
 
Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Developing Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKDeveloping Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDK
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15
 
Creating an hybrid app in minutes with Ionic Framework
Creating an hybrid app in minutes with Ionic FrameworkCreating an hybrid app in minutes with Ionic Framework
Creating an hybrid app in minutes with Ionic Framework
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
 
Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
An overview of mobile html + java script frameworks
An overview of mobile html + java script frameworksAn overview of mobile html + java script frameworks
An overview of mobile html + java script frameworks
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio Overview
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
 
Introduction_to_android_and_android_studio
Introduction_to_android_and_android_studioIntroduction_to_android_and_android_studio
Introduction_to_android_and_android_studio
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
 
Introduction to the Ionic Framework
Introduction to the Ionic FrameworkIntroduction to the Ionic Framework
Introduction to the Ionic Framework
 
Role of java in android app development
Role of java in android app developmentRole of java in android app development
Role of java in android app development
 

Viewers also liked

Website Re-design
Website Re-designWebsite Re-design
Website Re-designalbin500
 
MARELE LUP ALB_FRANCEZA
MARELE LUP ALB_FRANCEZAMARELE LUP ALB_FRANCEZA
MARELE LUP ALB_FRANCEZA
Gina Posirca
 
Sourcesofenergyyveth 140623084025-phpapp01
Sourcesofenergyyveth 140623084025-phpapp01Sourcesofenergyyveth 140623084025-phpapp01
Sourcesofenergyyveth 140623084025-phpapp01
Nalla Malla Reddy Engineering College
 
Introduction micemedia bv
Introduction micemedia bvIntroduction micemedia bv
Introduction micemedia bv
Eric Antonisse
 

Viewers also liked (6)

Website Re-design
Website Re-designWebsite Re-design
Website Re-design
 
MARELE LUP ALB_FRANCEZA
MARELE LUP ALB_FRANCEZAMARELE LUP ALB_FRANCEZA
MARELE LUP ALB_FRANCEZA
 
Dcmachine 1233234542827948-3
Dcmachine 1233234542827948-3Dcmachine 1233234542827948-3
Dcmachine 1233234542827948-3
 
Dcmachine 1233234542827948-3-1
Dcmachine 1233234542827948-3-1Dcmachine 1233234542827948-3-1
Dcmachine 1233234542827948-3-1
 
Sourcesofenergyyveth 140623084025-phpapp01
Sourcesofenergyyveth 140623084025-phpapp01Sourcesofenergyyveth 140623084025-phpapp01
Sourcesofenergyyveth 140623084025-phpapp01
 
Introduction micemedia bv
Introduction micemedia bvIntroduction micemedia bv
Introduction micemedia bv
 

Similar to Presentation1

Pertemuan 3 pm
Pertemuan 3   pmPertemuan 3   pm
Pertemuan 3 pm
obanganggara
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
Omolara Adejuwon
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionDuckMa
 
Android development
Android developmentAndroid development
Android development
mkpartners
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
lzongren
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
amaankhan
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions newJoe Jacob
 
Android app devolopment
Android app devolopmentAndroid app devolopment
Android app devolopment
SitCom Solutions
 
Android workshop
Android workshopAndroid workshop
Android workshop
Sagar Patel
 
Seminar on android app development
Seminar on android app developmentSeminar on android app development
Seminar on android app development
AbhishekKumar4779
 
Android
AndroidAndroid
Android
Tapan Khilar
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
Nandini Prabhu
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
Yogesh_Lakhole
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA
NITIN GUPTA
 
Android ppt
Android pptAndroid ppt
Android Applications
Android ApplicationsAndroid Applications
Android Applications
Nazeer Hussain University
 
Mobile Application Development powerpoint
Mobile Application Development powerpointMobile Application Development powerpoint
Mobile Application Development powerpoint
JohnLagman3
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdf
NomanKhan869872
 
Android Mobile App Development basics PPT
Android Mobile App Development basics PPTAndroid Mobile App Development basics PPT
Android Mobile App Development basics PPT
nithya697634
 

Similar to Presentation1 (20)

Pertemuan 3 pm
Pertemuan 3   pmPertemuan 3   pm
Pertemuan 3 pm
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
 
Android development
Android developmentAndroid development
Android development
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions new
 
Android app devolopment
Android app devolopmentAndroid app devolopment
Android app devolopment
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Seminar on android app development
Seminar on android app developmentSeminar on android app development
Seminar on android app development
 
Android
AndroidAndroid
Android
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android Applications
Android ApplicationsAndroid Applications
Android Applications
 
Android ppt
Android ppt Android ppt
Android ppt
 
Mobile Application Development powerpoint
Mobile Application Development powerpointMobile Application Development powerpoint
Mobile Application Development powerpoint
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdf
 
Android Mobile App Development basics PPT
Android Mobile App Development basics PPTAndroid Mobile App Development basics PPT
Android Mobile App Development basics PPT
 

Presentation1

  • 1. Android GUI Project John Hurley CS 454
  • 2. Android • 1. Android Basics • 2. Android Development • 3. Android UI • 4. Hello, World • 5. My Project
  • 3. Android Basics • Open source OS • Uses Linux kernel • Optimized for limited-resource environment • Apps typically written in Java • Apps run on the Dalvik Virtual Machine • Not a JVM, but works similarly from developer’s point of view • Usually one app per DVM • Each DVM runs under Linux as a separate user • App permissions set at install time • Possible to use C or C++ compiled to machine code, but still runs on VM. It’s not clear to me how this works. • Docs say it does not necessarily improve performance.
  • 4. Sams Teach Yourself Android™Application Development in 24 Hours (0321673352) Copyright ©2010 Lauren Darcey and Shane Conder FIGURE 5.6 Simplified Android platform architecture from a security perspective.
  • 5. Android Development • Well-defined framework for app development • Apps are typically coded using Java syntax, but other parts of the Java platform are missing • Some standard Java SE or ME APIs and class libraries are not included • I will give examples when I find out!
  • 6. Android Development • Standard development environment is Eclipse + Android Development Tools plugin + Android SDK • Development requires either an Android OS device or an emulator • Emulator has limitations: • Performance is poor • Camera, etc., simulated using your computer’s hardware • No real phone calls or texts • GPS data, battery readings, etc. must be simulated • Real device is affected by specific hardware and software configuration
  • 7. OS I was able to choose what kind of smart phone to get according to which platform I wanted to use to try mobile development Android: •I had Java backend code ready to go for a first project •Interesting platform: • Familiar programming environment • Currently the market leader • Broad market, unlike more focused iOS, Blackberry, and (Palm) webOS • Development tools are open source and are free even for commercial use, unlike Visual Studio
  • 8. Android App vs. Mobile- Optimized RIA • Android Flash plugins available; Silverlight coming soon • Could develop in JavaScript and/or HTML5 • WWW App • Easier for users to run; no need to install • For a paid app, avoid the 30% App Store commission • Easier to write cross-platform apps • Android Apps • Fewer security hurdles • Use APIs for access to built in GPS, camera, etc. • Probably better performance; one layer less
  • 9. Android Apps: Marketing • Usually market apps through Android App Market • There are other markets, also • App store will dominate the market due to access through built in app • Can set up for download directly on a website • User must agree to “install apps from unknown sources”
  • 10. Android Apps: Marketing • Revenue from app sales prices and/or advertising • Conventional wisdom is that iOS users will pay for apps, but Android users won’t • 57% of Android App Store apps are free, vs. 28% for Apple App Store • Android Market takes 30% commission • Any purchase model other than one-time purchase must be homegrown, using Paypal or similar service • PPC ads • My guess is that response to these is extremely low • Probably need to be very aggressive with banner ads • Sell to companies?
  • 11. Android Deployment • Apps are packaged in .apk format, variant of .jar, then downloaded to device and installed • .apks contain .dex files (bytecode), manifest and various other files • Manifest contains security and link info, hardware access info, minimum OS release info, etc.
  • 12. Android UI • Activity: single screen with a UI, somewhat analogous to XAML / code behind pattern in .NET • Email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails • Implement by subclassing Activity class • View: drawable object • Android UI View ≠ MVC View • UI contains a hierarchy of Views • View is a class, subclassed by the drawable objects in the UI
  • 13. Android UI • Service: background operation • play music in the background while the user is in a different application • fetch data over the network without blocking user interaction with an activity • Content Provider: DB or other data access • Broadcast Receiver: responds to system messages • Battery low
  • 14. Android UI • UI construction can be done in three ways: • Programmatic, like hand-coded Java desktop GUI construction • Declarative hand-written, like Java web UI construction • XML • Declarative with a GUI builder, like .NET UI construction • GUI builder generates the XML
  • 15. Programmatic UI package cs454.demo; import android.app.Activity; import android.widget.TextView; import android.os.Bundle; public class AndroidDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Activity is a subclass of context, so the TextView takes this as a parameter TextView tv = new TextView(this); tv.setText("Hello, CS454"); setContentView(tv); } }
  • 16. Manual Declarative UI main.xml Layout File: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> strings.xml resource file: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello Again, CS454!</string> <string name="app_name">CS454 AndroidDemo</string> </resources>
  • 17. Manual Declarative UI Java class: package cs454.demo; import android.app.Activity; import android.os.Bundle; public class AndroidDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  • 18. What’s R?/* AUTO-GENERATED FILE. DO NOT MODIFY. This class was automatically generated by the * aapt tool from the resource data it found. It should not be modified by hand. */ package cs454.demo; public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int textview=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; }
  • 19. UI With GUI Builder
  • 20. Android Event Handlers From the code file for the activity: Button ok = (Button) findViewById(R.id.button1); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CharSequence s = et.getText(); tv.setText("Welcome, " + s); } });
  • 21. Sams Teach Yourself Android™Application Development in 24 Hours (0321673352) Copyright ©2010 Lauren Darcey and Shane Conder FIGURE 3.2 Important callback methods of the activity life cycle.
  • 22. APIs for Android built-ins • Android OS ships with many built in apps • Web Browser • Google Maps • Navigation • Camera apps • Built in access for these as well as TTS and Voice Recognition, etc.
  • 23. Demo
  • 24. My Project • Goats and Tigers is a board game, which we implemented in Java in CS 460 last term. • The objective in CS460 was to implement the minmax / alpha beta pruning algorithm for the automatic player, not to create a good UI • My existing interface shows an ASCII art picture of the board and provides a JOptionPane menu of available moves • I will develop an Android UI and use my existing backend code as much as possible
  • 25. References • http://www.ibm.com/developerworks/opensource/library/os-android- devel/ • http://developer.android.com/resources/browser.html?tag=tutorial • Conder and Darcey, Android Wireless Application Development, Addison- Wesley, 2010 • Conder and Darcey, Sams Teach Yourself Android Application Development in 24 Hours, Sams, 2010