Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.

Slides:



Advertisements
Similar presentations
@2011 Mihail L. Sichitiu1 Android Introduction Communication between Activities.
Advertisements

Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Mobile Programming Lecture 9 Bound Service, Location, Sensors, IntentFilter.
Mobile Programming Lecture 16 The Facebook API. Agenda The Setup Hello, Facebook User Facebook Permissions Access Token Logging Out Graph API.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
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.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android - Broadcast Receivers
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Cosc 5/4730 QR codes. What is QR code? A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional code) first designed.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Android Android Sensors Android Sensors: – Accelerometer – Gravity sensor – Linear Acceleration sensor – Magnetic Field sensor – Orientation.
Sensors in Android.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors
Lab7 – Appendix.
Introduction to android
several communicating screens
Adapting to Display Orientation
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Android Dr. Vaishali D. Khairnar IT Department
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Communication between Activities
Android Widgets 1 7 August 2018
Android – Read/Write to External Storage
CS499 – Mobile Application Development
Android Introduction Camera.
Picasso Revisted.
CIS 470 Mobile App Development
CS323 Android Model-View-Controller Architecture
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Sensor Programming
CMPE419 Mobile Application Development
Activities and Intents
Activities and Intents
CIS 470 Mobile App Development
滑動 建國科技大學 資管系 饒瑞佶.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
Mobile Programming Sensors in Android.
Adding Components to Activity
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
Android Play YouTuBe 建國科技大學 資管系 饒瑞佶 2017/10 V1.
Activities, Fragments, and Intents
CIS 470 Mobile App Development
Mobile Programming Broadcast Receivers.
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Getting Started with Android APIs Ivan Wong

Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are available

Integrating Barcode Scanner barcode-reader--mobile-17162

Step 1: Create new App

Create Text Fields and Two Buttons <RelativeLayout xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textIsSelectable="true" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textIsSelectable="true" android:layout_centerHorizontal="true" /> Scan

Add Zebra Crossing (ZXING) from GitHub droid- integration/src/com/google/zxing/integration/android/ ?r=2002

@Override for Oncreate private Button scanBtn; private TextView formatTxt, protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); scanBtn = (Button)findViewById(R.id.scan_button); formatTxt = (TextView)findViewById(R.id.scan_format); contentTxt = (TextView)findViewById(R.id.scan_content); scanBtn.setOnClickListener(this); } public void onClick(View v){ //respond to clicks if(v.getId()==R.id.scan_button){ //scan IntentIntegrator scanIntegrator = new IntentIntegrator(this); scanIntegrator.initiateScan(); } public void onActivityResult(int requestCode, int resultCode, Intent intent) { //retrieve scan result IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanningResult != null) { //we have a result String scanContent = scanningResult.getContents(); String scanFormat = scanningResult.getFormatName(); formatTxt.setText("FORMAT: " + scanFormat); contentTxt.setText("CONTENT: " + scanContent); } else{ Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT); toast.show(); }

What can this be used for?  Integrating barcode scanning into your own application using ZXING library.  Learning how to use open-source APIs which can help you in your app-development career.

Quick look at using built in Accels _Detect_Phone_Shake_Motion/index.php?view=article_discription& aid=109&aaid=131 - Detecting phone movements (jerk) <RelativeLayout xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainAccelerometer" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Shake / Tilt Your Phone To Get Accelerometer Motion Alerts" />

MainAccel.java public void onShake(float force) { // Do your stuff here // Called when Motion Detected Toast.makeText(getBaseContext(), "Motion detected", Toast.LENGTH_SHORT).show(); public void onResume() { super.onResume(); Toast.makeText(getBaseContext(), "onResume Accelerometer Started", Toast.LENGTH_SHORT).show(); //Check device supported Accelerometer senssor or not if (AccelerometerManager.isSupported(this)) { //Start Accelerometer Listening AccelerometerManager.startListening(this); public void onStop() { super.onStop(); //Check device supported Accelerometer senssor or not if (AccelerometerManager.isListening()) { //Start Accelerometer Listening AccelerometerManager.stopListening(); Toast.makeText(getBaseContext(), "onStop Accelerometer Stoped", Toast.LENGTH_SHORT).show(); }}

Listener public interface AccelerometerListener { public void onAccelerationChanged(float x, float y, float z); public void onShake(float force); }

private static SensorEventListener sensorEventListener = new SensorEventListener() { public void onAccuracyChanged(Sensor sensor, int accuracy) {} public void onSensorChanged(SensorEvent event) { now = event.timestamp; x = event.values[0]; y = event.values[1]; z = event.values[2]; // if not interesting in shake events // just remove the whole if then else block if (lastUpdate == 0) { lastUpdate = now; lastShake = now; lastX = x; lastY = y; lastZ = z; Toast.makeText(aContext,"No Motion detected", Toast.LENGTH_SHORT).show(); } else { timeDiff = now - lastUpdate; if (timeDiff > 0) { /*force = Math.abs(x + y + z - lastX - lastY - lastZ) / timeDiff;*/ force = Math.abs(x + y + z - lastX - lastY - lastZ); if (Float.compare(force, threshold) >0 ) { //Toast.makeText(Accelerometer.getContext(), //(now-lastShake)+" >= "+interval, 1000).show(); if (now - lastShake >= interval) { // trigger shake event }; listener.onShake(force); } else { Toast.makeText(aContext,"No Motion detected", Toast.LENGTH_SHORT).show(); } lastShake = now; } lastX = x; lastY = y; lastZ = z; lastUpdate = now; } else { Toast.makeText(aContext,"No Motion detected", Toast.LENGTH_SHORT).show(); } // trigger change event listener.onAccelerationChanged(x, y, z); }

Applications? For you to be creative!