Android Programming วรเศรษฐ ส วรรณ ก.

Similar documents
Programming with Android: The Google Maps Library. Slides taken from

External Services. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion

Lecture 13 Mobile Programming. Google Maps Android API

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

Google Maps library requires v2.50 or above.

IEMS 5722 Mobile Network Programming and Distributed Server Architecture

Programming with Android: Geo-localization and Google Map Services. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

LifeStreet Media Android Publisher SDK Integration Guide

Mobila applikationer och trådlösa nät

Lab 6: Google Maps Android API v2 Android Studio 10/14/2016

UNDERSTANDING ACTIVITIES

<uses-permission android:name="android.permission.internet"/>

Vienos veiklos būsena. Theory

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Android Application Development. By : Shibaji Debnath

Intents. Your first app assignment

DEPARTMENT OF COMPUTER SCIENCE THE UNIVERSITY OF HONG KONG. CSIS0801 Final Year Project. WhozzUp - A Novel Big Data App for HK (Individual Report)

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Computer Science E-76 Building Mobile Applications

Presented by: Megan Bishop & Courtney Valentine

Real-Time Embedded Systems

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015


Embedded Systems Programming - PA8001

M.A.D Assignment # 1

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

LECTURE NOTES OF APPLICATION ACTIVITIES

Designing Apps Using The WebView Control

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

Cheetah Orion Ad Platform SDK Guide (for Android) V1.0

Fragments and the Maps API

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

Create Parent Activity and pass its information to Child Activity using Intents.

Mobile Application Development MyRent Settings

Android - JSON Parser Tutorial

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Android Tutorial: Part 3

CS 234/334 Lab 1: Android Jump Start

Upcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26

Android Programs Day 5

Our First Android Application

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Activities. Repo:

VAMK ANDROID APPLICATION

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

TomTom Mobile SDK QuickStart Guide

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking

PROFILE MANAGER ANDROID APPLICATION. A Project. Presented to the faculty of the Department of Computer Science

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

ANDROID PROGRAMS DAY 3

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Introduction To Android

An Overview of the Android Programming

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

Press project on the left toolbar if it doesn t show an overview of the app yet.

Android Development Tutorial

API Guide for Gesture Recognition Engine. Version 2.0

Update to newest version and translate to English.


M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

Fragment Example Create the following files and test the application on emulator or device.

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Lab 1: Getting Started With Android Programming

INTRODUCTION TO ANDROID

Overview of Activities

Lecture 14. Android Application Development

Android/Java Lightning Tutorial JULY 30, 2018

Google Maps Troubleshooting

android-espresso #androidespresso

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

ELET4133: Embedded Systems. Topic 15 Sensors

East West University

Manifest.xml. Activity.java

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

SMART VEHICLE TRACKING APPLICATION

Android Apps Development for Mobile Game Lesson 5

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence

CS371m - Mobile Computing. Maps

Arrays of Buttons. Inside Android

AdFalcon Android SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Android Workshop: Model View Controller ( MVC):

UI Fragment.

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

EMBEDDED SYSTEMS PROGRAMMING Application Basics

ABSTRACT I. INTRODUCTION. E. Susmitha, M. Himabindu M.Tech Academic Assistant, IIIT Rk Valley, Rgukt, Andhra Pradesh, India

Android UI Development

Tabel mysql. Kode di PHP. Config.php. Service.php

Xin Pan. CSCI Fall

Transcription:

Android Programming วรเศรษฐ ส วรรณ ก uuriter@yahoo.com http://bit.ly/wannikacademy 1

Google Map API v2 2

Preparation SDK Manager Google Play Services AVD Google API >= 4.2.2 [http://bit.ly/1hedxwm] https://developers.google.com/maps/documentation/android/start 3

API Key 4

API Key 5

API Key 6

API Key 7

API Key 8

API Key : ADT Preferences 9

API Key 10

API Key 11

Manifest <manifest> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-sdk android:minsdkversion="14" android:targetsdkversion="14" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <application>... <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="---------apikey-----------" /> </application> </manifest> 12

Layout <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:name="com.google.android.gms.maps.mapfragment" android:layout_width="match_parent" android:layout_height="match_parent" /> 13

Activity package com.example.testmap; import android.app.activity; import android.os.bundle; public class MainActivity extends Activity { @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } } 14

Normal 15

Map Type GoogleMap map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); map.setmaptype(googlemap.map_type_hybrid); https://developers.google.com/maps/documentation/android/map 16

Hybrid 17

Initial Location latitude north-south 90 to -90 longitude east-west 180 to -180 GoogleMap map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap();; map.movecamera(cameraupdatefactory.newlatlng(new LatLng(13.8484877,100.5715896))); map.movecamera(cameraupdatefactory.zoomto(16.4f)); https://developers.google.com/maps/documentation/android/map 18

Initial Location 19

Location <uses-permission android:name="android.permission.access_fine_location" /> GPS, cell tower, WIFI implies <uses-permission android:name="android.permission.access_coarse_location" /> cell tower, WIFI 20

Current Location import com.google.android.gms.common.googleplayservicesclient.connectioncallbacks; import com.google.android.gms.common.googleplayservicesclient.onconnectionfailedlistener; public class MainActivity extends Activity implements ConnectionCallbacks, OnConnectionFailedListener { LocationClient lc; GoogleMap map; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lc = new LocationClient(this, this, this); map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); } 21

Current Location @Override protected void onstart() { super.onstart(); lc.connect(); } @Override protected void onstop() { lc.disconnect(); super.onstop(); } 22

Current Location @Override public void onconnectionfailed(connectionresult arg0) { } @Override public void onconnected(bundle arg0) { Log.i("map", "connect"); Location loc = lc.getlastlocation(); LatLng latlng = new LatLng(loc.getLatitude(), loc.getlongitude()); map.animatecamera(cameraupdatefactory.newlatlng(latlng)); } } @Override public void ondisconnected() { Log.i("map", "disconnect"); } 23

Current Location 24

Current Location map.setmylocationenabled(true); 25

Location Listener @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); locationclient = new LocationClient(this, this, this); map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); locationrequest = LocationRequest.create(); locationrequest.setpriority(locationrequest.priority_high_accuracy); locationrequest.setinterval(5); locationrequest.setfastestinterval(1); } 26

Location Listener @Override public void onconnected(bundle arg0) { locationclient.requestlocationupdates(locationrequest, new LocationListener() { @Override public void onlocationchanged(location loc) { LatLng latlng = new LatLng(loc.getLatitude(), loc.getlongitude()); map.animatecamera(cameraupdatefactory.newlatlng(latlng)); } }); } 27

Click Listener map.setonmapclicklistener(new OnMapClickListener() { @Override public void onmapclick(latlng latlng) { Log.i("map", latlng.latitude + " " + latlng.longitude); } }); long click listener 28

Click Listener map.setonmapclicklistener(new OnMapClickListener() { @Override public void onmapclick(latlng latlng) { Log.i("map", latlng.latitude + " " + latlng.longitude); } }); long click listener 29

Marker public class MainActivity extends Activity { GoogleMap map; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); map.addmarker(new MarkerOptions().position(new LatLng(0, 0)).title( "Center of the World")); } 30

Marker 31

Marker public class MainActivity extends Activity { GoogleMap map; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } map = ((MapFragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); map.addmarker(new MarkerOptions().position(new LatLng(0, 0)).title( "Center of the World")); } https://developers.google.com/maps/documentation/android/marker 32

Marker 33

Marker 34

Marker Marker marker = map.addmarker(new MarkerOptions().position(new LatLng(0, 0)).title("Center of the World")); // try snippet marker.showinfowindow(); // map.setonmarkerclicklistener https://developers.google.com/maps/documentation/android/infowindows 35

Shape PolylineOptions rectoptions = new PolylineOptions().add(new LatLng(0, 0)).add(new LatLng(30, 10)).add(new LatLng(35, 20)).add(new LatLng(60, 30)).add(new LatLng(0, 0)).width(5).color(Color.BLUE).geodesic(true); map.addpolyline(rectoptions); A geodesic is the shortest path between two points on the Earth's surface. The geodesic curve is constructed assuming the Earth is a sphere. http://bit.ly/1mz3pk5 https://developers.google.com/maps/documentation/android/shapes 36

Shape 37

CRUD Marker Map Long Click add marker (color, alpha), ask for a title, log position Click marker show info window Click info window pop up menu => 38