Android 3: Exploring Apps and the Development Environment

Slides:



Advertisements
Similar presentations
Ando-it-yourself droid Praveen Kumar Pendyala. Outline Brief intro to the Droid developement Setting up the Life saviors - Development tools Hello Droid.
Advertisements

All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Software Development. Chapter 3 – Your first Windows 8 app.
Android 4: Creating Contents Kirk Scott 1. Outline 4.1 Planning Contents 4.2 GIMP and Free Sound Recorder 4.3 Using FlashCardMaker to Create an XML File.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Android Application Development 2013 PClassic Chris Murphy 1.
Android 2: A First Project Kirk Scott Creating a New, Example Android Application Project in Eclipse 2.2 Creating a Virtual Device, an Emulator.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Android 2: Introduction to the Technology Kirk Scott 1.
Android 6: Testing and Running the App Kirk Scott 1.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Using Eclipse. What is Eclipse? The Eclipse Platform is an open source IDE (Integrated Development Environment), created by IBM for developing Java programs.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Intro to Android Development Ben Lafreniere. Getting up and running Don’t use the VM! ials/hello-world.html.
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Android 3: Exploring Apps and the Development Environment Kirk Scott 1.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Unit 1: Java and Eclipse The Eclipse Development Environment.
Android Hello World 1. Click on Start and type eclipse into the textbox 2.
Creating an Example Android App in Android Studio Activity lifecycle & UI Resources.
Android 3: Exploring Apps and the Development Environment Kirk Scott 1.
First Venture into the Android World Chapter 1 Part 2.
Android 2: A First Project Kirk Scott Creating a New, Example Android Application Project in Eclipse 2.2 Creating a Virtual Device, an Emulator.
Intoduction to Andriod studio Environment With a hello world program.
Editing and Debugging Mumps with VistA and the Eclipse IDE Joel L. Ivey, Ph.D. Dept. of Veteran Affairs OI&T, Veterans Health IT Infrastructure & Security.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
CHAPTER 1 part 1 Introduction. Chapter objectives: Understand Android Learn the differences between Java and Android Java Examine the Android project.
Introduction to Android Programming
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Appendix A 12.0 Workbench Environment
Android 3: Exploring Apps and the Development Environment
Chapter 1 ANSYS Workbench
Lab7 – Appendix.
Lab7 – Advanced.
Android Mobile Application Development
Development Environment
Chapter 2: The Visual Studio .NET Development Environment
Mobile Application Development BSCS-7 Lecture # 2
Working in the Forms Developer Environment
Introduction to Eclipse
Android 1: Background Kirk Scott.
Obtaining the Required Tools
Android 3: First Project, Hello World, and Exploring the Development Environment Kirk Scott.
Android Studio, Android System Basics and Git
Data Virtualization Tutorial: XSLT and Streaming Transformations
Introduction Purpose Objectives Content Learning Time
Android 11: The Calculator Assignment
MAD.
Eclipse Navigation & Usage.
RAD Certification Checkpoint #2 Introducing RadStudio (Hello World)
Android 10: The Silly String App
Intro to PHP & Variables
Anatomy of an Android Application
Android 10: The Silly String App
Android 3: First Project, Hello World, and Exploring the Development Environment Kirk Scott.
Android 8: Wari and Togiz Kumalak Programming
Some Tips for Using Eclipse
Unreal Engine and C++ We’re finally at a point where we can start working in C++ with Unreal Engine To get everything set up for this properly, we’re going.
1. Open Visual Studio 2008.
Using JDeveloper.
Using Eclipse.
Presentation transcript:

Android 3: Exploring Apps and the Development Environment Kirk Scott

Introduction This unit surveys some of the code aspects of an Android app It also surveys how you can find these aspects of an app through the Eclipse interface The unit is not intended as a comprehensive treatment of these topics

It is intended to answer the questions that might spring to the mind of a programmer who is seeing app development for the first time It is also motivated by this simple goal: How could you change MyFirstApp, the “Hello World” app so that it displayed a different message?

The outline for this unit is shown on the following overheads As you will see, this outline corresponds to parts of the project as they would appear in the Project Explorer in Eclipse

Outline 3.1 The Project Explorer 3.2 /src/com.example.myfirstapp/ Main_Activity.java 3.3 /gen/com.example.myfirstapp/ BuildConfig.java 3.4 /gen/com.example.myfirstapp/R.java 3.5 Android 4.3 and Android Private Libraries

3.6 /bin/res/AndroidManifest.xml 3.7 /bin/res/MyFirstApp.apk 3.8 /res/layout/activity_main.xml 3.9 /res/menu/main.xml 3.10 /res/values/strings.xml 3.11 Grand Finale

3.1 The Project Explorer

The screenshot on the following overhead shows the hello world app as it was shown in the previous overheads The key point of interest at this moment is the Project Explorer on the left hand side As given here, the MyFirstApp folder has been expanded to show the items immediately underneath it

No matter where’ve you’ve gotten to in Eclipse, you can always restore the Project Explorer Take these options in the menu: Window, Show View, Project Explorer

Expanded View of the Project in the Explorer The screenshot on the following overhead shows the subfolders in the Project Explorer expanded to show the items in the outline of this unit The following sections of this unit look at items of interest in these expanded folders one after the other from top to bottom

Once things are expanded, not everything is visible in the screenshot at the bottom If you are following along on your own machine, depending on the setup, you may have to scroll down to see some of it

In the screenshot, Android 4.3 hasn’t been expanded It will be dealt with separately Future versions of these overheads may continue to show Android 4.3 even if the version number has changed, assuming that nothing else about it that’s being explained here has changed

3.2 /src/com.example.myfirstapp/Main_Activity.java

The screenshot on the overhead following the next one shows what you see when you double click on Main_Activity.java in the Project Explorer This is essentially the Java source code for the app Notice that unlike a Java application, there is no main() method

The app code is slightly reminiscent of applet code, if you are familiar with that The app class extends the Activity class Instead of a main() method it has (overrides) an onCreate() method Most of the details mean nothing at this point, but note that in the code, reference is made to a class name R

3.3 /gen/com.example.myfirstapp/BuildConfig.java

If you double click on BuildConfig If you double click on BuildConfig.java in the Project Explorer you see what’s shown on the overhead following the next one This is an auto-generated file It’s worth knowing that it exists, but for the time being the details aren’t important

In the previous unit it wasn’t necessary to go through building a configuration step-by-step We let the configuration come into existence by default instead In any case, an app that has been brought to the point of being runnable will have a build configuration

3.4 /gen/com.example.myfirstapp/R.java

If you double click on R.java in the Project Explorer you see what’s shown on the overhead following the next one R.java is another auto-generated file It is too soon for details, but it is worth knowing that R.java is kind of a global container associated with an app

Note that it contains final declarations, the declarations of constants associated with the app It’s also apparent that hexadecimal values are being used It will be of interest later to see how to make use of the constants defined in the file R

3.5 Android 4.3 and Android Private Libraries

The screenshot on the following overhead shows a subset of what you see when you double click on Android 4.3 in the Project Explorer, on the left (The file R.java is still showing in the editor) The Android 4.3 folder is a library which contains Android packages and if you were to scroll down further, you would find Java packages The Android Private Libraries folder is similar In effect, what you’re seeing is the set of API packages available when creating Android apps

3.6 /bin/res/AndroidManifest.xml The screenshot on the following overhead shows what you see when you double click on AndroidManifest.xml in the Project Explorer You may recall that jar files have manifest files An Android apk file, the result of building a project, is effectively a kind of jar file Therefore, every completed app will have a manifest file associated with it

3.7 /bin/res/MyFirstApp.apk

This section starts with some information taken from Wikipedia, starting on the following overhead

APK (file format) From Wikipedia, the free encyclopedia Android application package file (APK) is the file format used to distribute and install application software and middleware onto Google's Android operating system. To make an APK file, a program for Android is first compiled, and then all of its parts are packaged into one file. This holds all of that program's code (such as .dex files), resources, assets, certificates, and manifest file. As is the case with many file formats, APK files can have any name needed, but must end with the four character, three letter extension, .apk.[1][2][3][4]

APK files are ZIP file formatted packages based on the JAR file format, with .apk file extensions. The MIME type associated with APK files is application/vnd.android.package-archive.[5]

In short, the apk file is a jar file for an Android app, which packages up the manifest and the compiled source code for distribution The screenshot on the following overhead shows what you see when you double click on MyFirstApp.apk in the Project Explorer Not surprisingly, it looks more or less like what you see when you open up a class file in an editor—binary nonsense

3.8 /res/layout/activity_main.xml

The screenshot on the following overhead shows what you see when you double click on activity_main.xml under /res/layout in the Project Explorer As seen before, this is the layout of the output of the app as shown in the development environment The layout is developed separately from the code logic, so it’s important to be able to find activity_main.xml in order to be able to work with it

Consider the contents of the screenshot again: On the left, there is the Eclipse Project Explorer, with the folders expanded In the center, there is a view of the graphical layout of the app This visible graphical layout is defined by the file activity_main.xml

Between the explorer and the layout is a palette of graphical tools and components for creating visual layouts for apps At the bottom of the editor are two tabs, one for Graphical Layout and one simply showing the name of the file, activity_main.xml Clicking on the activity_main.xml tab shows you the xml source code, as shown on the following overhead

The layout file includes layout syntax It also includes lines like this: android:text="@string/hello_world“ This refers to a resource belonging to the app which is defined elsewhere in the environment The relationship between resources and references is an important aspect of app development

3.9 /res/menu/main.xml

The screenshot on the following overhead shows what you see when you double click on main.xml under /res/menu in the Project Explorer There is nothing of consequence here for the moment It is simply included to bring to your attention the fact that the layout you’re familiar with is /res/layout/activity_main.xml, not what you see here

3.10 /res/values/strings.xml

The screenshot on the following overhead shows the Project Explorer scrolled down to show /res/values/strings.xml It also shows what you see when you double click on strings.xml (Note that of the two tabs at the bottom of the editor screen, you need to be on strings.xml, not Resources, if you want to see the XML source code)

What about strings.xml? strings.xml is the last item on this tour of things to be found in the explorer Practically speaking, it’s also the most significant at this point We are finally in the place where we can make a simple, initial modification to the app

In the original version of the app, this line appeared in strings.xml: <string name="hello_world">Hello world!</string> If you look carefully at the foregoing screenshot, you’ll see that the line has been changed to this: <string name="hello_world">Good-Bye Cruel World!</string>

The code for the app displays a resource by reference The resource, a string, is defined in strings.xml, separate from the app code This is a significant feature of Android development that will be dwelled on in following sets of overheads

3.11 Grand Finale

At this point, if you’ve made changes to strings At this point, if you’ve made changes to strings.xml, you can go back to the MainActivity.java, as shown on the following screenshot A change in the output string of the app requires absolutely no change in the Java source code

From MainActivity.java, you can run your application, whether on the emulator or on an attached device When you click run, you’ll be prompted to save the changes to strings.xml if you didn’t save out of that editor screen Ta-Da: The following screenshot shows success on the emulator

Summary and Mission This is the end of the initial presentation of the components of an app that can be found in the Project Explorer High points of what can be found there: MainActivity.java, the source code activity_main.xml, the layout strings.xml, the file containing the string resources for an app R.java, the file containing resources as defined in the Java code for the app

You have two missions, neither of which are graded homework: 1. Create a new Android project and modify it so that its output is not “Hello World” This should work, and should consist essentially of changing strings.xml The point of this mission is obviously not the importance of the change The point is finding strings.xml and reinforcing what relationship it has with the app code

2. Things related to this were mentioned only in passing in this set of overheads, but it’s not too soon for you to conduct a small experiment in preparation for coming attractions Using the palette of graphical tools for activity_main.xml, drag and drop some new item into the layout for an app

Note the contents of R.java before building the project Then try building the project and consider two things: A. Do you get error messages? If so, what are they, and what do they imply? B. Were there any changes in R.java?

The point of the second mission is not necessarily for you to have a firm grasp on what’s going on The point is just to have you find activity_main.xml, fiddle with the graphical tools palette, and then find R.java in the explorer

The End