Write your own Android App

Malling U3A Advanced Computer Group Write your own Android App Chris Daly – 19th January 2016 Apps  What are Apps ?  App is short for Applicat...
Author: Allan Daniel
1 downloads 1 Views 1MB Size
Malling U3A Advanced Computer Group

Write your own Android App Chris Daly – 19th January 2016

Apps 

What are Apps ?



App is short for Application Software - this can be any type of computer program.



Mobile native apps are different to software apps that run on desktop computers, or to web apps, which run in mobile web browsers rather than directly on the mobile device.



Applications have been around for as long as computers, but 'app' is now usually associated with software that runs on a smartphone or tablet



Means you don't need to search for a program, or key in the address of a website.



Many apps make use of the built-in features of the smartphone such as the camera or GPS - which is used for location-based services and maps.

Apps 

In 2013 there were 102 billion apps downloaded.



91% were free



2013 estimated revenue generated in US was $102 Billion



Of that Google Play Store & Apple Store revenue was $5 Billion.



2013 estimated revenue generated in EU was Euro10 Billion



2013 estimate of 529,000 jobs generated in EU.

Apps (Development) 

Apps are unique to the operating system on a device, so can be for iphone, android, blackberry, windows phone etc



Apps are written using Java which needs to be learnt first, and then used within a special development environment, on a PC, within which are all the tools needed.



Android is an operating system based on Linux with a Java programming interface, and was developed by Google as an operating system.



Normally the Eclipse Integrated Development Environment (IDE) is used for Android Apps.

Apps (Development) 

On your PC would normally be installed :– Eclipse IDE – Latest Java Development Kit – Android Software Development Kit



In the IDE an “activity” is created for each screen of your App & the program logic is implemented in Java.



Apps can be tested on your own devices.



Within Eclipse is an Android Virtual Device Manager to run your apps on devices with hardware and software specifications of your choice.

Apps 

What if you have an idea for an app and want to develop it quickly without learning Java and all the other code ? – Pay someone else to design & develop your app at a suitable cost. – Go to a company with a web based system using templates, to be published and hosted by the Company. Pay a monthly fee. http://appinstitute.com/ – Build your own App with free Drag and Drop building blocks, which Google developed as part of their open source concept for Android.

Apps (Development) 

Google introduced “App Inventor” in 2009.



Google's Mark Friedman and MIT Professor Hal Abelson co-led the development of App Inventor while Hal was on sabbatical at Google in 2009.



Updated & revised in 2013 to App Inventor 2.



App Inventor runs as a web service administered by staff at MIT’s Center for Mobile Learning - a collaboration of MIT’s Computer Science and Artificial Intelligence Laboratory (CSAIL) and the MIT Media Lab.



MIT App Inventor Mission Statement – The MIT App Inventor project seeks to democratize software development by empowering all people, especially young people, to transition from being consumers of technology to becoming creators of it.

App Inventor 

App Inventor – Based on a visual “blocks” programming method. – A visual, drag-and-drop tool for building mobile apps on the Android platform. – You design the user interface (the visual appearance) of an app using a web-based graphical user interface (GUI) builder. – Then you specify the app’s behavior by piecing together “blocks” as if you were working on a puzzle.

App Architecture

App Architecture 

App Inventor architecture

App Inventor 

The App Inventor programming environment has three key parts: – The Component Designer. You use it to select components for your app and specify their properties. – The Blocks Editor. You use it to specify how the components will behave (e.g., what happens when a user clicks a button). – An Android device with which you can actually run and test your app as you are developing it. If you don’t have an Android device handy, you can test the apps you build by using the Android emulator that comes with the system.

App Inventor (Components) 

Component Designer



There are two main types of components in an app: visible and non-visible. – Visible components are the ones you can see when the app is launched—things like buttons, text boxes, and labels. • These are often referred to as the app’s user interface. – Non-visible components are not part of the user interface. They provide access to the built-in functionality of the device; for example: • Texting component sends and processes SMS texts • LocationSensor component determines the device’s location. • TextToSpeech component talks.

App Inventor (Components) 

The non-visible components are the technology within the device (little people that do jobs for your app)



Both visible and non-visible components are defined by a set of properties.



Properties are memory slots for storing information about the component.



Visible components, for instance, have properties like Width, Height, and Alignment, which together define how the component looks. – So a button that looks like the Submit button to the end user, is defined in the Component Designer with a set of properties.

App Inv – Component Designer

App Inv - Blocks 

App Behaviour



An app’s components are generally straightforward to understand: – A text box is for entering information – A button is for clicking, and so on.



An app’s behaviour, defines how the app should respond to events. – User initiated (e.g., a button click) – External (e.g., an SMS text arriving to the phone).



App Inventor provides a visual “blocks” language, perfectly suited for specifying behaviours.

App Inv - Blocks 

App as a recipe



Traditionally, software has often been compared to a recipe. Like a recipe, a traditional app follows a linear sequence of instructions such as those shown below that the computer (chef) should perform.



A typical app might – start a bank transaction (A) – perform some computations & modify a customer’s account (B) – Print out the new balance on the screen (C)

App Inv - Blocks 

App As a Set of Event Handlers



Most apps today, whether they’re for mobile phones, Web, or desktop computers, don’t fit the recipe paradigm anymore.



They don’t perform a set of instructions in a predetermined order; instead, they react to events. – Click a button, the app responds e.g., sending a text



– Dragging your finger across the screen is another event. App might respond to that event by drawing a line following your finger These types of apps are better conceptualized as a set of components that respond to events.

App Inv - Blocks 

These apps do include “recipes”—sequences of instructions—but each recipe is only performed in response to some event.

App Inv - Blocks 

The responses to events are not always linear recipes; they can ask questions and repeat operations.



“Asking questions” means to query the data the app has stored and determine its course based on the answers.

App Inv - Blocks 

Many events are initiated by the end user, but some are not.



An app can react to events that happen within the phone: – Changes to its orientation sensor – Changes to the clock (i.e., the passing of time)



OR events created by things outside the phone – Other phones nearby – Data arriving from the Web

App Inv – Blocks Editor

App Inv – Blocks Editor 

App Inventor programming is intuitive as it’s based directly on the event-response paradigm; event handlers are primary “words” in the language (in many programming languages, this is not the case).



You begin defining a behaviour by dragging out an event block, which has the form, “When do”.



Consider an app, SpeakIt, that responds to button clicks by speaking the text the user has entered aloud.



This app could be programmed with a single event handler

App Inv – Blocks Editor

App Inventor - Use 

Setting up App Inventor



The Designer and Blocks Editor run completely in the browser. (Not IE) To see your app on a device while you build it (also called "Live Testing"), you'll need to follow the steps below.



If you are using an Android device & a wireless internet connection, you can start building apps without downloading any software to your computer. You will need to install the App Inventor Companion App for your device.

App Inventor - Use 

Setting up App Inventor



If you do not have an Android device, you'll need to install software on your computer so that you can use the on-screen Android emulator.

App Inventor - Use 

Setting up App Inventor



If you do not have a wireless internet connection, you'll need to install software on your computer so that you can connect to your Android device over USB. The USB Connection option can be tricky, especially on Windows. Use this as a last resort.

App Inventor - Use 

Setting up App Inventor



There are two websites that can be used to learn. – MIT App Inventor - http://appinventor.mit.edu/explore/about-us.html • This is the original MIT team and has all necessary learning tutorials and guides. – Appinventor.org - http://www.appinventor.org/about • This is based at the University of San Francisco and has “refined versions of the tutorials that have been on the Google and MIT App Inventor sites from App Inventor's inception” • Designed for use by teachers with suitable material available to help them.

App Inventor - Use 

Setting up App Inventor



Using the MIT website gives all the instructions and tutorials necessary.

To access the “App Inventor Software” in a browser a Google account is required, then click “Create Apps” in top RH corner

App Inventor - Use

App Inventor - Use

App Inventor - Use 

Setting up App Inventor (with emulator)



Download and install the App Inventor Software package



Launch aiStarter



Open an App Inventor project and connect to the emulator

App Inventor - Use

App Inventor - Use 

Setting up App Inventor (with WiFi phone)



Download and install the AI2 Companion App onto device.



Connect PC & App on device to the same WiFI network.



Open an App Inventor project and connect to your device – Choose “Connect” & “AI Companion” from top menu in AI2 browser

App Inventor - Use 

Setting up App Inventor (with WiFi phone)



A dialog with QR code will appear on PC screen.



Launch AI2 Companion app as you would any other app.



Click “scan QR code” button and read the QR code on PC.



Within a few seconds you will see your project on the device.

App Inventor - Use 

The easiest way to learn is by following a tutorial in video or pdf format.



There are also App Inventor Concept Cards and Maker Cards – Concept cards offer concise summaries of some of the basic concepts of making apps. Great for use in the classroom or on your own. – Maker Cards help new users get started quickly with miniapps that can be made during the course of a short workshop or class.



Both the websites listed earlier have a full program of lessions, and books are available to purchase or download.

App Inventor - Use 

After completion the App is saved by default, and stored, on the MIT servers.



The App can then be saved to your PC as an .apk file using the “Build” menu.



Then load onto any device using a USB cable or Airdroid.



Airdroid is a computer application for Windows/Mac, using wifi to send SMS, view app notifications, transfer files and fully control your phone.



Now get started !!