Vijay Kumar Kolagani Dr. Yingcai Xiao

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google.
Advertisements

Programming Mobile Applications with Android
Get android development environment running. Install – Get and install JDK 5 or 6 (see link in the.
Android: Hello World Frank Xu Gannon University. Steps Configuration ▫Android SDK ▫Android Development Tools (ADT)  Eclipse plug-in ▫Android SDK and.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
UFCFX5-15-3Mobile Device Development Android Development Environments and Windows.
Setting up the Development Environment Copyright © SUPINFO. All rights reserved Preparation.
SET UP COMPUTER ** PLEASE BE AWARE SCREENSHOTS MAY NOT MATCH **
CS378 - Mobile Computing Sensing and Sensors. Sensors "I should have paid more attention in Physics 41" Most devices have built in sensors to measure.
CS378 - Mobile Computing Sensing and Sensors. Sensors "I should have paid more attention in Physics 41" Most devices have built in sensors to measure.
Android Introduction Platform Overview.
Android Programming By Mohsen Biglari Android Programming, Part1: Introduction 1 Part1: Introduction By Mohsen Biglari.
Lecture # 9 Hardware Sensor. Topics 2  SensorManger & Sensor  SensorEvent & SensorEventListener  Example Application.
Sensing. Possible sensors on devices – Documented in SensorEvent class Accelerometer (m/s 2 ) – acceleration in x, y, z axes Magnetic Field (micro Tesla)
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.
Basic Android Tutorial USF’s Association for Computing Machinery.
Doodlz App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
#gsa2012 Android Basics By: Amr Mohsen
Presented By: Muhammad Tariq Software Engineer Android Training course.
Sensors – Part I SE 395/595.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Android Development Environment Environment/tools Windows Eclipse IDE for Java Developers (v3.5 Galileo) Java Platform (JDK 6 Update 18) Android.
Using and developing on the Android Dev Phone 1. Setup At the gmail credentials screen, skip the step Go to Settings->Wireless Controls  Enable Wi-Fi.
Sensors in android. App being more applicable Keeping track of your heart beat while jogging. Pointing the phone camera towards the night sky to know.
TODAY Android Studio Installation Getting started Creating your 1 st App Beginning to understanding Intents.
Sensors For Mobile Phones  Ambient Light Sensor  Proximity Sensor  GPS Receiver Sensor  Gyroscope Sensor  Barometer Sensor  Accelerometer Sensor.
Installation of Visual Studio Android emulator and Android Studio
Intoduction to Andriod studio Environment With a hello world program.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
Accelerometer based motion gestures for mobile devices Presented by – Neel Parikh Advisor Committee members Dr. Chris Pollett Dr. Robert Chun Dr. Mark.
CPE 490/590 – Smartphone Development
LOGO iPhone to Galaxy Note Transfer Transfer iPhone Data to Galaxy Note 3/Note 4/Note 5/Note Edge.
CHAPTER 8 Sensors and Camera. Chapter objectives: Understand Motion Sensors, Environmental Sensors and Positional Sensors Learn how to acquire measurement.
CS371m - Mobile Computing Sensing and Sensors.
The Doodlz app enables you to paint by dragging one or more fingers across the screen. The app provides options for setting the drawing color.
IBM Worklight environment setup 1. Eclipse IDE Multi-purpose integrated development environment (IDE) Open source Supported for Windows, Mac OS X, Linux.
Day 1 Session 2. Setup & Installation
Introduction to Android Programming
Android Android Sensors Android Sensors: – Accelerometer – Gravity sensor – Linear Acceleration sensor – Magnetic Field sensor – Orientation.
COM594: Mobile Technology Practical – Week 1 Android and Android Studio.
The Basics of Android App Development Sankarshan Mridha Satadal Sengupta.
Android Programming.
Sensors in Android.
Vijay Kumar Kolagani Dr. Yingcai Xiao
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors
Mobile Device Development
Android Mobile Application Development
Obtaining the Required Tools
Sai Goud Durgappagari Dr. Yingcai Xiao
Android.
Cross Platform Development using Software Matrix
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Development-Introduction
Sensors, maps and fragments:
Vijay Kumar Kolagani Dr. Yingcai Xiao
CS499 – Mobile Application Development
CA16R405 - Mobile Application Development (Theory)
CS371m - Mobile Computing Sensing and Sensors.
How to Fix Android File Transfer Not Working on Mac?
CS323 Android Getting Started
Packing and Signing of the Application
Android Developer Fundamentals V2
Android Topics Sensors Accelerometer and the Coordinate System
Android Programming Tutorial
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Android Application Development
Mobile Programming Sensors in Android.
Android Platform, Android App Basic Components
Presentation transcript:

Vijay Kumar Kolagani Dr. Yingcai Xiao Android Vijay Kumar Kolagani Dr. Yingcai Xiao

Introduction 2003, Blackberry introduced first widely used smart phone. Smart phone OS dominated by android and iPhone. Android was initially developed by Android, Inc. Acquired by google in 2005. 2007, development taken over by Open Handset Alliance. Open source, written in a form of java, using an XML tag set for the displays.

ANDROID Development Tools

Development Tools Android software are developed with IDEs (Integrated Development Environment). We will use Android Studio: https://developer.Android.Com/studio/index.html You can also use Eclipse for Android developers: http://www.Eclipse.Org/downloads/eclipse-packages/ You also need two development toolkits: Java Development Kit (JDK) http://www.oracle.com/technetwork/java/javase/downloads/index.html Android Development Toolkit (ADT) included in Android Studio and Eclipse for Android.

ANDROID STUDIO SETUP

Setup Android Studio Android studio : https://developer.Android.Com/studio/index.html Download the dmg file and open it to install. Select standard installation. Start Android Studio. It may check and update latest Android SDK. For the very first time you run the application, you will be asked to select a screen configuration.

Setup Android Studio

PROGRAMMING with android studio

Programming with Android Studio Start Android Studio Import an Android code sample Select an existing sample (say, Universal Music Player). Update any components when asked to do so. Run->Run. Select Deployment Target Connected Devices or Virtual Devices It will automatically deploy the app to the device you selected and run it there.

Programming with Android Studio

DEPLOY ANDROID APP

Programming with Android Studio You can also create build an APK file to distribute. Build->Build APK(s) Update any components when asked to do so. A prompt screen will show up when done building for you to locate and analyze the APK. C:\Users\xiao\AndroidStudioProjects\UniversalMusicPlayer\mobile\build\outputs\apk\mobile- debug.apk Email it to yourself. On your phone, save the attachment from your gmail. The app will be automatically installed.

Vysor interacting with your phone on a computer

Vysor: interacting with your phone on a computer To interact with your Android phone on a computer, download Vysor. http://www.vysor.io/ You can download it for Windows, Mac, Linux or Chrome For windows, you also need to download ADB https://adb.clockworkmod.com/

Vysor: interacting with your phone on a computer On your Android phone: Settings Develop options (if your don’t see the options, go to “About Phone”, click “Build number” several times until it says you are now a developer. :-). Turn on USB Debugging USB configuration: Select MTP (Media Transfer Protocol)

Vysor: interacting with your phone on a computer Connect you phone to the computer’s USB port. You computer should automatically detects the phone and prompt you to start Vysor. If not, start Vysor youself. Select the device to view. If Vysor does not detect you device, do the following: Make sure your USB cable is the original data cable not just a charging cable. Restart you computer and restart your phone. If still not working, remove and reinstall Vysor and ADB.

Vysor

ANDROID INPUT DEVICES

Android Interactions Voice Control Touch Screen Sensor Control

Sensors Overview The Android platform supports three broad categories of sensors: Motion sensors: these sensors measure acceleration forces and rotational forces along three axes. This category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors. Environmental sensors: these sensors measure various environmental parameters, such as ambient air temperature and pressure, illumination, and humidity. This category includes barometers, photometers, and thermometers. Position sensors: these sensors measure the physical position of a device. This category includes orientation sensors and magnetometers. http://www.bluebugle.org/smartphone-sensors/

Android EDP CODING

Identifying sensors and sensor capabilities. Basic programming tasks: Identifying sensors and sensor capabilities. Identify sensor events to monitor. Write handlers for them.

Sensor Framework The sensor framework is part of the android.Hardware package and includes the following classes and interfaces: Sensormanager You can use this class to create an instance of the sensor service. This class provides various methods for accessing and listing sensors, registering and unregistering sensor event listeners, and acquiring orientation information. This class also provides several sensor constants that are used to report sensor accuracy, set data acquisition rates, and calibrate sensors. Sensor You can use this class to create an instance of a specific sensor. This class provides various methods that let you determine a sensor's capabilities. Sensorevent The system uses this class to create a sensor event object, which provides information about a sensor event. A sensor event object includes the following information: the raw sensor data, the type of sensor that generated the event, the accuracy of the data, and the timestamp for the event. Sensoreventlistener You can use this interface to create two callback methods that receive notifications (sensor events) when sensor values change or when sensor accuracy changes.

Identifying sensors and sensor capabilities Create an instance of the sensormanager class by calling the getsystemservice() method and passing in the sensor_service argument. We can determine whether A specific type of sensor exists on A device by using the getdefaultsensor() method and passing in the type constant for A specific sensor for example: private SensorManager mSensorManager; ... mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); if (mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null){ // Success! There's a Accelerometer. } else { // Failure! No Accelerometer. }

Monitoring Sensor Events To monitor raw sensor data you need to implement two callback methods that are exposed through the sensoreventlistener interface: onaccuracychanged() and onsensorchanged() this methods are called whenever the following occurs: A sensor's accuracy changes. In this case the system invokes the onaccuracychanged() method, providing you with a reference to the sensor object that changed and the new accuracy of the sensor. Accuracy is represented by one of four status constants SENSOR_STATUS_ACCURACY_LOW, SENSOR_STATUS_ACCURACY_MEDIUM,SENSOR_STATUS_ACCURACY_HIGH, or SENSOR_STATUS_UNRELIABLE. A sensor reports a new value. In this case the system invokes the onsensorchanged() method, providing you with a sensorevent object. A sensorevent object contains information about the new sensor data, including: the accuracy of the data, the sensor that generated the data, the timestamp at which the data was generated, and the new data that the sensor recorded.

An example using Accelerometer Accelerometer measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), including the force of gravity. This example uses the Accelerometer to roll a group of balls.

An example using Accelerometer Accelerometer_Android Studio Project Directory \app\src\main\java\com\example\android\accelerometerplay AccelerometerPlayActivity.java Public void onsensorchange(sensorevent sensorevent) {     sensor mysensor = sensorevent.Sensor;       If (mysensor.Gettype() == sensor.Type_accelerometer) {         float x = sensorevent.Values[0];         Float y = sensorevent.Values[1];         Float z = sensorevent.Values[2];     } }

An example using Accelerometer Accelerometer_Android Studio Project Directory \app\src\main\java\com\example\android\accelerometerplay AccelerometerPlayActivity.java Public void onsensorchange(sensorevent sensorevent) {     sensor mysensor = sensorevent.Sensor;       If (mysensor.Gettype() == sensor.Type_accelerometer) {         float x = sensorevent.Values[0];         Float y = sensorevent.Values[1];         Float z = sensorevent.Values[2];     } }

Converting Unity3D Games to Android Apps

CODE Modification Check if it is android platform or not in the Start function. #if UNITY_ANDROID currentPlatformAndroid = true; #Else currentPlatformAndroid = false; #Endif

CODE Modification In the FixedUpdate() function and other event handlers, if (currentPlatformAndroid == true) { // Write code for Android Mobile } else // Write code for Desktop

CODE Modification Android specific coding public void Accelerometer() { float x = Input.acceleration.x; float y = Input.acceleration.y; if (x < -0.1f) MoveLeft(); else if (x > 0.1f) MoveRight(); else if (y < -0.1f) MoveUp(); else if (y > 0.1f) MoveDown(); else SetVelocityZero(); }

CODE Modification Code common to all platforms. public void MoveLeft() { rb.velocity = new Vector3(-speed, 0,0); }   public void MoveRight() { rb.velocity = new Vector3(speed, 0,0); public void MoveUp() { rb.velocity = new Vector3(0, 0, speed); public void MoveDown() { rb.velocity = new Vector3(0, 0, -speed); public void SetVelocityZero() { rb.velocity = Vector3.zero;

UNITY project BUILD Modification IN UNITY, File  Build Setting Switch Platform from PC, MAC, Linux to Android File  Build Settings  PlayerSettings Specify Comopany Name, Product Name, builder Identifier

UNITY project BUILD Modification Connect an Android phone to your computer using USB. File  Build & Run It will ask you to run on the connected Android phone or a virtual device. You can also build an .APK file to distribute to others (.APK files are executables for Android) File  Build  Build Once the build is done, it will ask for a location to save the APK file. Now you can email the APK file to your friends and let them save it on their Android mobile device to run.

UNITY project BUILD Modification If you are working on Windows, you may get an error message about incorrect sdk path. You then need to download tools_r25.2.3-windows.zip https://developer.android.com/studio/index.html Unzip it. You Unzip it you will find a “tools” folder. Use it to replace the “tools” folder Android SDK directory.

References https://code.tutsplus.com/tutorials/using-the-accelerometer-on-android-- mobile-22125 https://developer.android.com/about/versions/nougat/index.html https://docs.unity3d.com/ScriptReference/Input-acceleration.html