SlideShare una empresa de Scribd logo
1 de 44
Beginning Native Android Apps
Gil Irizarry
Conoa, Inc.
Your logo on white
centered in this space
Launched VC News Daily app on iOS and Android. Over 3000
downloads so far. Also, check out @wazareapp.
Owner and lead engineer at Conoa, a graphics and mobile software firm
gil@conoa.com
http://www.slideshare.net/conoagil/
About Me
All examples and sample code in this presentation can be found at:
http://conoa.com/hidden/sig2015examples.zip
About Me
There are nearly 4 million mobile apps available today.
http://www.statista.com/statistics/276623/number-of-apps-available-in-
leading-app-stores/
In 2015, there will be approximately 180 billion app downloads.
http://www.statista.com/statistics/266488/forecast-of-mobile-app-
downloads/
For many, interacting with software means interacting with mobile
devices (or at least devices that run mobile software).
Why?
Learn some basic Android concepts
Look at the structure of an Android app
Access the device
Do some rendering
What we will do
Android 1.5 – Cupcake
Android 1.6 – Donut
Android 2.0 – Eclair, HTML5 support, Bluetooth 2.1
Android 2.2 – Froyo, USB tethering and WiFi hotspot functionality
Android 2.3 – Gingerbread, aimed at tablets, support for large screens
Android 3.0 – Honeycomb, 3D desktop, better tablet support
Android 4.0 – Ice Cream Sandwich
Android 4.1 – Jelly Bean
Android 4.3 – KitKat
Android 5.0 – Lollipop
Android M – developer preview currently
https://en.wikipedia.org/wiki/Android_version_history
Android Versions
https://upload.wikimedia.org/wikipedia/commons/a/af/Android-System-Architecture.svg
The Android Stack
The android stack, from top to bottom:
Applications: app built with the Java framework
Android framework: com.android….
Dalvik VM: for running Java code
Native framework: native code
Linux kernel
The Android Stack
As a developer, you can choose to develop with the SDK or NDK.
Android SDK – provides the framework
Android NDK – for compiling to native code
Android ADB – (android debug bridge) the emulator and debugger
Android Eclipse Plug-in
Android Studio
Android Development
Example 1 - Hello World
Manifest
- An Android app must list the set of permissions it needs and device
capabilities it will use. This list is contained in the manifest file. The
manifest file allows the user to understand what capabilities an app has
when installing it.
The structure of an app
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.siggraph2015.example1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion=”8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=”com.siggraph2015.example1.FirstActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
The structure of an app
Activities and intents
- An Android activity maps to a user screen. If you had an app with
a splash screen, a menu and news reader, that app would have 3
activities. An activity is a class that you subclass to modify.
- Intents connect activities. They allow control to flow from one
screen to another.
The structure of an app
https://upload.wikimedia.org/wikipedia/en/f/f6/Android_application_life_cycle.png
Activity lifecycle
Views
- An Android activity contains a layout with one or more views.
Views allow presenting information to the user. Widgets are subclasses
of views and have specialized behavior. Examples of widgets are:
- Lists
- Buttons
- Images
- Dialog boxes
The structure of an app
Example 2 - Layouts
Before running Example 2, do the following:
cd C:Program Fileseclipseplatform-tools
adb shell
su
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit
exit
adb push pic1.jpg /sdcard
adb push pic2.jpg /sdcard
Example 2 - Prep the emulator
Example 2 - Prep the emulator
Views allow drawing and event handling for a region of the screen.
Groups are a subclass of a View that allows organization of Views.
Layouts are subclasses of Groups that add properties to Groups.
Layouts may contain other layouts.
Layouts
Linear Layout - aligns all children in a single direction, vertically or
horizontally.
Relative Layout - displays child views in relative positions.
Table Layout - groups views into rows and columns.
Absolute Layout - enables you to specify the exact location of its
children.
Frame Layout - placeholder on screen that you can use to display a
single view.
List View - displays a list of scrollable items.
Grid View - displays items in a two-dimensional, scrollable grid.
Layouts
<RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
android:layout_width="match_parent”
android:layout_height="match_parent”
android:background="@android:color/white" >
<ImageView
android:id="@+id/imageView1”
android:src="@drawable/siglogo" />
<ImageView
android:id="@+id/imageView2”
android:layout_below="@+id/imageView1”
android:layout_toRightOf="@+id/imageView1”
android:scaleType="fitXY”
android:src="@drawable/lacc" />
<LinearLayout
android:layout_below="@+id/text1”>
<Button
Layouts
Example 3 - Input / internet access
Need to set permissions in the manifest file that are needed by the app:
<uses-permission android:name="android.permission.INTERNET" />
Set callbacks in the layout file:
<Button
android:onClick="clearSubmit” />
<Button
android:onClick="symbolSubmit” />
Permissions and actions
Intents pass control between activities. Data can be added to them to
be consumed by the target activity. Do this with an “extra”. Extras are
simply key/value pairs.
Intent thisIntent = new Intent(mContext, DisplayQuote.class);
thisIntent.putExtra("symbol", editText.getText().toString());
startActivity(thisIntent);
In the target activity:
Bundle bundle = this.getIntent().getExtras();
mSymbol = bundle.getString("symbol");
In the code, the symbol is used to construct the URL for HTTP request.
Data Passing between activities
Example 4 - Contact Lists
Make sure to add some contacts to the emulator.
Example 4 - Prep the emulator
Need to set permissions in the manifest file that are needed by the app:
<uses-permission
android:name="android.permission.READ_CONTACTS" />
Set callbacks in the layout file:
<Button
android:onClick="clearSubmit” />
<Button
android:onClick="symbolSubmit” />
Permissions
Content providers manage access to a structured set of data. They
encapsulate the data, and provide mechanisms for defining data
security.
When you want to access data in a content provider, you use the
ContentResolver object in your application's Context to communicate
with the provider as a client.
Cursors provide random read-write access to the result set returned by
a database. The example uses a Cursor to loop over the data returned
from a query of the Resolver.
Providers, Resolvers and Cursors
Example 5 - Scrollable lists
ListView can be used to give the appearance of an infinitely scrollable
list:
Define a ListView in the activity layout.
Define a class for each ListView item, and create associated layout.
Define an adapter to bind the ListView to the item class.
We are able to set a listener on each ListView item:
listView.setOnItemClickListener(new OnItemClickListener()
Scrollable Lists
In addition to ListView, there is also ExpandableListView.
In ExpandableListView, each list item will open to reveal a larger layout
when touched.
Expandable List Items
Example 6 - access GPS location
Make sure to add some contacts to the emulator.
Example 4 - Prep the emulator
Example 4 - Prep the emulator
Need to set permissions in the manifest file that are needed by the app:
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
Permissions
Need to implement a LocationListener:
public class GetLocation extends Activity implements
LocationListener {
Then the app can be called when the location changes:
public void onLocationChanged(Location location) {
txtLat = (TextView) findViewById(R.id.locationview);
txtLat.setText("Latitude:" + location.getLatitude() + ",
Longitude:" + location.getLongitude());
}
LocationListener
Example 7 - using the camera
Need to set permissions in the manifest file that are needed by the app:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Permissions
A subclass of SurfaceView gets the camera and starts previewing.
The activity binds that SurfaceView to the FrameLayout defined in the
layout file.
In the example, the listener on the button forces the camera to take a
picture, calling the camera callback method for taking a picture. Here
we can get the raw bitmap of the image.
What if we wanted to do image processing on preview?
Previewing the Camera
Example 8 - OpenGL rendering
Android bundles OpenGL ES – OpenGL for Embedded Systems
Since Android 2.2, there has been support for OpenGL ES 1.0. Later
versions of Android support OpenGL ES 2.0. You can query the
platform to see which version of OpenGL ES is supported and make the
appropriate rendering calls.
OpenGL rendering
The activity is bound to a surface. The surface is what gets drawn and
receives events.
The surface is bound to a renderer. The renderer contains the code for
rendering.
OpenGL rendering
The example code calls queueEvent when wanting to render.
This is needed because GLSurfaceView creates a separate rendering
thread. You can’t make rendering calls directly in the UI thread.
queueEvent queues request from other threads to the surface thread for
rendering.
Why queueEvent?
Set version in the manifest file
Build the .apk file
Digitally sign it
Create developer account
Upload to Google Play developer console
Submitting to the App Store

Más contenido relacionado

La actualidad más candente

OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
Pamela Fox
 
View groups containers
View groups containersView groups containers
View groups containers
Mani Selvaraj
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
Ahsanul Karim
 
Demystifying Keyword Driven Using Watir
Demystifying Keyword Driven Using WatirDemystifying Keyword Driven Using Watir
Demystifying Keyword Driven Using Watir
Hirday Lamba
 

La actualidad más candente (20)

Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
Developing accessible android applications
Developing accessible android applicationsDeveloping accessible android applications
Developing accessible android applications
 
Android accessibility for developers and QA
Android accessibility for developers and QAAndroid accessibility for developers and QA
Android accessibility for developers and QA
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
 
View groups containers
View groups containersView groups containers
View groups containers
 
Android Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection WidgetAndroid Tutorials - Powering with Selection Widget
Android Tutorials - Powering with Selection Widget
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
 
Modern android development
Modern android developmentModern android development
Modern android development
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Demystifying Keyword Driven Using Watir
Demystifying Keyword Driven Using WatirDemystifying Keyword Driven Using Watir
Demystifying Keyword Driven Using Watir
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
Unit2
Unit2Unit2
Unit2
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Angular material
Angular materialAngular material
Angular material
 
Android Layout.pptx
Android Layout.pptxAndroid Layout.pptx
Android Layout.pptx
 

Similar a Beginning Native Android Apps

Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
AbdullahMunir32
 
android layouts
android layoutsandroid layouts
android layouts
Deepa Rani
 

Similar a Beginning Native Android Apps (20)

Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
 
android layouts
android layoutsandroid layouts
android layouts
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 
Hello Android
Hello AndroidHello Android
Hello Android
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
android level 3
android level 3android level 3
android level 3
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
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
 

Más de Gil Irizarry

Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
Gil Irizarry
 
Building The Agile Enterprise - LSSC '12
Building The Agile Enterprise - LSSC '12Building The Agile Enterprise - LSSC '12
Building The Agile Enterprise - LSSC '12
Gil Irizarry
 
Agile The Kanban Way - Central MA PMI 2011
Agile The Kanban Way - Central MA PMI 2011Agile The Kanban Way - Central MA PMI 2011
Agile The Kanban Way - Central MA PMI 2011
Gil Irizarry
 
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
Gil Irizarry
 
Transitioning to Kanban - Aug 11
Transitioning to Kanban - Aug 11Transitioning to Kanban - Aug 11
Transitioning to Kanban - Aug 11
Gil Irizarry
 

Más de Gil Irizarry (16)

A Rose By Any Other Name.pdf
A Rose By Any Other Name.pdfA Rose By Any Other Name.pdf
A Rose By Any Other Name.pdf
 
[Apple-organization] and [oranges-fruit] - How to evaluate NLP tools - Basis ...
[Apple-organization] and [oranges-fruit] - How to evaluate NLP tools - Basis ...[Apple-organization] and [oranges-fruit] - How to evaluate NLP tools - Basis ...
[Apple-organization] and [oranges-fruit] - How to evaluate NLP tools - Basis ...
 
[Apple|organization] and [oranges|fruit]: How to evaluate NLP tools for entit...
[Apple|organization] and [oranges|fruit]: How to evaluate NLP tools for entit...[Apple|organization] and [oranges|fruit]: How to evaluate NLP tools for entit...
[Apple|organization] and [oranges|fruit]: How to evaluate NLP tools for entit...
 
Ai for Good: Bad Guys, Messy Data, & NLP
Ai for Good: Bad Guys, Messy Data, & NLPAi for Good: Bad Guys, Messy Data, & NLP
Ai for Good: Bad Guys, Messy Data, & NLP
 
DevSecOps Orchestration of Text Analytics with Containers
DevSecOps Orchestration of Text Analytics with ContainersDevSecOps Orchestration of Text Analytics with Containers
DevSecOps Orchestration of Text Analytics with Containers
 
Towards Identity Resolution: The Challenge of Name Matching
Towards Identity Resolution: The Challenge of Name MatchingTowards Identity Resolution: The Challenge of Name Matching
Towards Identity Resolution: The Challenge of Name Matching
 
RapidMiner - Don’t Forget to Pack Text Analytics on Your Data Exploration Jou...
RapidMiner - Don’t Forget to Pack Text Analytics on Your Data Exploration Jou...RapidMiner - Don’t Forget to Pack Text Analytics on Your Data Exploration Jou...
RapidMiner - Don’t Forget to Pack Text Analytics on Your Data Exploration Jou...
 
From Silos to DevOps: Our Story
From Silos to DevOps:  Our StoryFrom Silos to DevOps:  Our Story
From Silos to DevOps: Our Story
 
Graphics on the Go
Graphics on the GoGraphics on the Go
Graphics on the Go
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
 
Building The Agile Enterprise - LSSC '12
Building The Agile Enterprise - LSSC '12Building The Agile Enterprise - LSSC '12
Building The Agile Enterprise - LSSC '12
 
Agile The Kanban Way - Central MA PMI 2011
Agile The Kanban Way - Central MA PMI 2011Agile The Kanban Way - Central MA PMI 2011
Agile The Kanban Way - Central MA PMI 2011
 
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
Transitioning to Kanban: Theory and Practice - Project Summit Boston 2011
 
Transitioning to Kanban - Aug 11
Transitioning to Kanban - Aug 11Transitioning to Kanban - Aug 11
Transitioning to Kanban - Aug 11
 
Transitioning to Kanban
Transitioning to KanbanTransitioning to Kanban
Transitioning to Kanban
 
Beyond Scrum of Scrums
Beyond Scrum of ScrumsBeyond Scrum of Scrums
Beyond Scrum of Scrums
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Beginning Native Android Apps

  • 1. Beginning Native Android Apps Gil Irizarry Conoa, Inc. Your logo on white centered in this space
  • 2. Launched VC News Daily app on iOS and Android. Over 3000 downloads so far. Also, check out @wazareapp. Owner and lead engineer at Conoa, a graphics and mobile software firm gil@conoa.com http://www.slideshare.net/conoagil/ About Me
  • 3. All examples and sample code in this presentation can be found at: http://conoa.com/hidden/sig2015examples.zip About Me
  • 4. There are nearly 4 million mobile apps available today. http://www.statista.com/statistics/276623/number-of-apps-available-in- leading-app-stores/ In 2015, there will be approximately 180 billion app downloads. http://www.statista.com/statistics/266488/forecast-of-mobile-app- downloads/ For many, interacting with software means interacting with mobile devices (or at least devices that run mobile software). Why?
  • 5. Learn some basic Android concepts Look at the structure of an Android app Access the device Do some rendering What we will do
  • 6. Android 1.5 – Cupcake Android 1.6 – Donut Android 2.0 – Eclair, HTML5 support, Bluetooth 2.1 Android 2.2 – Froyo, USB tethering and WiFi hotspot functionality Android 2.3 – Gingerbread, aimed at tablets, support for large screens Android 3.0 – Honeycomb, 3D desktop, better tablet support Android 4.0 – Ice Cream Sandwich Android 4.1 – Jelly Bean Android 4.3 – KitKat Android 5.0 – Lollipop Android M – developer preview currently https://en.wikipedia.org/wiki/Android_version_history Android Versions
  • 8. The android stack, from top to bottom: Applications: app built with the Java framework Android framework: com.android…. Dalvik VM: for running Java code Native framework: native code Linux kernel The Android Stack
  • 9. As a developer, you can choose to develop with the SDK or NDK. Android SDK – provides the framework Android NDK – for compiling to native code Android ADB – (android debug bridge) the emulator and debugger Android Eclipse Plug-in Android Studio Android Development
  • 10. Example 1 - Hello World
  • 11. Manifest - An Android app must list the set of permissions it needs and device capabilities it will use. This list is contained in the manifest file. The manifest file allows the user to understand what capabilities an app has when installing it. The structure of an app
  • 12. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.siggraph2015.example1" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion=”8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=”com.siggraph2015.example1.FirstActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> The structure of an app
  • 13. Activities and intents - An Android activity maps to a user screen. If you had an app with a splash screen, a menu and news reader, that app would have 3 activities. An activity is a class that you subclass to modify. - Intents connect activities. They allow control to flow from one screen to another. The structure of an app
  • 15. Views - An Android activity contains a layout with one or more views. Views allow presenting information to the user. Widgets are subclasses of views and have specialized behavior. Examples of widgets are: - Lists - Buttons - Images - Dialog boxes The structure of an app
  • 16. Example 2 - Layouts
  • 17. Before running Example 2, do the following: cd C:Program Fileseclipseplatform-tools adb shell su mount -o rw,remount rootfs / chmod 777 /mnt/sdcard exit exit adb push pic1.jpg /sdcard adb push pic2.jpg /sdcard Example 2 - Prep the emulator
  • 18. Example 2 - Prep the emulator
  • 19. Views allow drawing and event handling for a region of the screen. Groups are a subclass of a View that allows organization of Views. Layouts are subclasses of Groups that add properties to Groups. Layouts may contain other layouts. Layouts
  • 20. Linear Layout - aligns all children in a single direction, vertically or horizontally. Relative Layout - displays child views in relative positions. Table Layout - groups views into rows and columns. Absolute Layout - enables you to specify the exact location of its children. Frame Layout - placeholder on screen that you can use to display a single view. List View - displays a list of scrollable items. Grid View - displays items in a two-dimensional, scrollable grid. Layouts
  • 21. <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width="match_parent” android:layout_height="match_parent” android:background="@android:color/white" > <ImageView android:id="@+id/imageView1” android:src="@drawable/siglogo" /> <ImageView android:id="@+id/imageView2” android:layout_below="@+id/imageView1” android:layout_toRightOf="@+id/imageView1” android:scaleType="fitXY” android:src="@drawable/lacc" /> <LinearLayout android:layout_below="@+id/text1”> <Button Layouts
  • 22. Example 3 - Input / internet access
  • 23. Need to set permissions in the manifest file that are needed by the app: <uses-permission android:name="android.permission.INTERNET" /> Set callbacks in the layout file: <Button android:onClick="clearSubmit” /> <Button android:onClick="symbolSubmit” /> Permissions and actions
  • 24. Intents pass control between activities. Data can be added to them to be consumed by the target activity. Do this with an “extra”. Extras are simply key/value pairs. Intent thisIntent = new Intent(mContext, DisplayQuote.class); thisIntent.putExtra("symbol", editText.getText().toString()); startActivity(thisIntent); In the target activity: Bundle bundle = this.getIntent().getExtras(); mSymbol = bundle.getString("symbol"); In the code, the symbol is used to construct the URL for HTTP request. Data Passing between activities
  • 25. Example 4 - Contact Lists
  • 26. Make sure to add some contacts to the emulator. Example 4 - Prep the emulator
  • 27. Need to set permissions in the manifest file that are needed by the app: <uses-permission android:name="android.permission.READ_CONTACTS" /> Set callbacks in the layout file: <Button android:onClick="clearSubmit” /> <Button android:onClick="symbolSubmit” /> Permissions
  • 28. Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. Cursors provide random read-write access to the result set returned by a database. The example uses a Cursor to loop over the data returned from a query of the Resolver. Providers, Resolvers and Cursors
  • 29. Example 5 - Scrollable lists
  • 30. ListView can be used to give the appearance of an infinitely scrollable list: Define a ListView in the activity layout. Define a class for each ListView item, and create associated layout. Define an adapter to bind the ListView to the item class. We are able to set a listener on each ListView item: listView.setOnItemClickListener(new OnItemClickListener() Scrollable Lists
  • 31. In addition to ListView, there is also ExpandableListView. In ExpandableListView, each list item will open to reveal a larger layout when touched. Expandable List Items
  • 32. Example 6 - access GPS location
  • 33. Make sure to add some contacts to the emulator. Example 4 - Prep the emulator
  • 34. Example 4 - Prep the emulator
  • 35. Need to set permissions in the manifest file that are needed by the app: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> Permissions
  • 36. Need to implement a LocationListener: public class GetLocation extends Activity implements LocationListener { Then the app can be called when the location changes: public void onLocationChanged(Location location) { txtLat = (TextView) findViewById(R.id.locationview); txtLat.setText("Latitude:" + location.getLatitude() + ", Longitude:" + location.getLongitude()); } LocationListener
  • 37. Example 7 - using the camera
  • 38. Need to set permissions in the manifest file that are needed by the app: <uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Permissions
  • 39. A subclass of SurfaceView gets the camera and starts previewing. The activity binds that SurfaceView to the FrameLayout defined in the layout file. In the example, the listener on the button forces the camera to take a picture, calling the camera callback method for taking a picture. Here we can get the raw bitmap of the image. What if we wanted to do image processing on preview? Previewing the Camera
  • 40. Example 8 - OpenGL rendering
  • 41. Android bundles OpenGL ES – OpenGL for Embedded Systems Since Android 2.2, there has been support for OpenGL ES 1.0. Later versions of Android support OpenGL ES 2.0. You can query the platform to see which version of OpenGL ES is supported and make the appropriate rendering calls. OpenGL rendering
  • 42. The activity is bound to a surface. The surface is what gets drawn and receives events. The surface is bound to a renderer. The renderer contains the code for rendering. OpenGL rendering
  • 43. The example code calls queueEvent when wanting to render. This is needed because GLSurfaceView creates a separate rendering thread. You can’t make rendering calls directly in the UI thread. queueEvent queues request from other threads to the surface thread for rendering. Why queueEvent?
  • 44. Set version in the manifest file Build the .apk file Digitally sign it Create developer account Upload to Google Play developer console Submitting to the App Store