Android Development (Basics)

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

Chapter 3: Engage! Android User Input, Variables, and Operations
Chapter 6: Jam! Implementing Audio in Android Apps.
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.
Manifest File, Intents, and Multiple Activities. Manifest File.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Application Development 2013 PClassic Chris Murphy 1.
Better reference the original webpage :
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Introducing the Sudoku Example
Cosc 5/4730 Information, Resources, and basic GUI concepts.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
CS5103 Software Engineering Lecture 08 Android Development II.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Chapter 2: Simplify! The Android User Interface
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Chapter 5 Creating User Interfaces GOALS and OBJECTIVES Begin our application by creating our user interface. More than one way to create a user interface.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Engage! Android User Input, Variables,
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Android Boot Camp for Developers Using Java, 3E
Chapter 7: Reveal! Displaying Pictures in a Gallery.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
© 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.
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.
First Venture into the Android World Chapter 1 Part 2.
Topics Introduction Scene Graphs
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
© 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.
© 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.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Cosc 5/4735 YouTube API. YouTube The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
Menus. Menus are a common user interface component in many types of applications. The options menu is the primary collection of menu items for an activity.
Chapter 2: Simplify! The Android User Interface
Lab7 – Advanced.
Android Programming - Features
Weebly Elements, Continued
Mobile Development Workshop
Android – Event Handling
Android Moving to a second Activity
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Android Boot Camp for Developers Using Java, 3E
Mobile Application Development Chapter 5 [Persistent Data in Android]
Android Widgets 1 7 August 2018
Android Programming Lecture 4
Android Studio Hello World
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Cosc 4730 An Introduction.
Presentation transcript:

Android Development (Basics) Sina ABedi

Getting Started Go to http://developer.android.com/sdk/index.html and download the latest version of Android Studio Once installed, open Android Studio and click “File -> New Project” Pick a name for your app and pick any domain name for now. You can use uwaterloo.ca Only check “Phone and Tablet”, set API to API 15 and click next Click on “Blank Activity” and click next Click “Finish”

First Activity You will now have 2 files open: MainActivity.java activity_main.xml These files are responsible for the main page in your activity. Right now, you only have one page. MainActivity.java is responsible for all of the different functions that particular page performs. activity_main.xml is responsible for the layout of that page and how it looks on the phone.

MainActivity.java You will see some imports and a package name at the top There should be three methods inside this java file: void onCreate(Bundle savedInstanceState) boolean onCreateOptionsMenu(Menu menu) boolean onOptionsItemSelected(MenuItem item)

Methods The onCreate() of an activity gets called on the start of that particular activity The onOptionsItemSelected() deals with the different options available in the action bar The onCreateOptionsMenu() gets called when the action bar is first created. This is the Action Bar: Image Source: www.androidhive.info

Java vs. C# Java has no properties. Instead of properties, Java uses methods to access or change data bool should be boolean in Java In Java, you must declare string as String (Capital S) instead int.Parse or the likes will not work in Java. Must use Integer.parseInt(value) or Double.parseDouble(value) etc. foreach(string s in array) must be written as: for(string s : array) “import” is the equivalent of “using” in C# “final” in Java is the equivalent of “const” in C# To call the base constructor in a child class, you need to use “super(parameters)” instead of “base(parameters)” For a more comprehensive list of differences, check out Google or StackOverFlow

Android Manifest You will see AndroidManifest.xml under manifests The Android Manifest file is responsible for all of the permissions your app uses (like internet access), name of the app, icon of the app, all of the activities that the app contains, etc. Every time you create a new activity, the manifest gets updated by the IDE to include the new activity In the example shown, there are two activities, the name of the app is “beepo” and MainActivity is the main activity(starts when the app is launched)

Button Click Listeners Let’s try making a very basic app that displays a word that the user enters on the screen after a button is pressed First we must make the button inside the xml file for MainActivity Open activity_main.xml. In the “Design” tab, you will see multiple widgets and layouts that you can implement Drag “Button” and put it inside the phone display Now for the user input, drag “Plain Text” from the Text Fields Now go to the “Text” tab and look at android:id for the button and the EditText since we will need these.

Declare two global variables Declare two global variables. One of type EditText and one of type Button (If you get an error for these, press alt + enter on them to import these classes. I called these variables e1 and b1 respectively) You must now instantiate these variables inside the onCreate method with the following code: e1 = (EditText)findViewById(R.id.editText); Remember those ids in the previous page? We use them here.(R.id.whateverIdYouhaveinXML) b1 = (Button)findViewById(R.id.button); Now Android knows what e1 and b1 are. Now we must do b1.setOnClickListener(new OnClickListener). Android Studio will automatically fill this for you if you enter new OnClickListener. This will create an onClick method inside of the setOnClickListener for you. onClick is where all the action happens. Let’s get the text that the user stored by declaring userInput inside the onClick method: String userInput = e1.getText().toString(); getText() will get whatever was in the editText and toString() will convert it to a string for you to use.

To use a toast, we must create it and call the show() method on it: Now that we have onClick method, we need to display userInput onto the phone. This is done by using something called a Toast. To use a toast, we must create it and call the show() method on it: Toast.makeText(MainActivity.this, userInput, Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG is just an integer that says to your phone how long the Toast should be visible The first parameter is the context in which the Toast shows up in and this context has to be the MainActivity. To signify the context of MainActivity, we use MainActivity.this. Your onCreate should look like this: Try Googling and figuring out how to use the different widgets now (Look at CheckBox, ProgressBar, ImageView and Toggle Switch)