GABRIELLI Adrian PREDA Marius

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

Fragments: Introduction Fragments were introduced in Android 3.0 to support flexible and dynamic UI designs represent portions of an application’s user.
Location-Based Services: Part 2 (Google Maps)
Manifest File, Intents, and Multiple Activities. Manifest File.
The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
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.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
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.
CS5103 Software Engineering Lecture 08 Android Development II.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
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.
Mobile Programming Lecture 6
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Android for Java Developers Denver Java Users Group Jan 11, Mike
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Copyright© Jeffrey Jongko, Ateneo de Manila University Of Activities, Intents and Applications.
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
Android – Fragments L. Grewe.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Maps Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Android Application Lifecycle and Menus
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Intoduction to Andriod studio Environment With a hello world program.
Lecture 2: Android Concepts
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
Lab7 – Appendix.
Introduction to android
Lecture 2: Android Concepts
Android 01: Fundamentals
Location-Based Services: Part 2 (Google Maps)
Activity and Fragment.
Adapting to Display Orientation
GUI Programming Fundamentals
Android Studio, Android System Basics and Git
Fragments: Introduction
CS499 – Mobile Application Development
Sensors, maps and fragments:
Android Introduction Camera.
Android – Fragments L. Grewe.
ANDROID UI – FRAGMENTS UNIT II.
Recap: Android Components
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CS5103 Software Engineering
CMPE419 Mobile Application Development
Activities and Intents
Activities and Intents
CIS 470 Mobile App Development
Objects First with Java
CMPE419 Mobile Application Development
Activities and Fragments
Mobile Programming Dr. Mohsin Ali Memon.
Chapter 5 Your Second Activity.
CIS 470 Mobile App Development
Android Sensor Programming
Presentation transcript:

GABRIELLI Adrian PREDA Marius

 Introduction  Timeline  Basics  Activity lifecycle  ADT/Eclipse IDE  Install and Configure  Emulators, APIs, debugger  Project Structure  ex1: Hello World  GUI  Colors and Fonts  Action Bar  Menu Bar  Activities  Exercise 2  Fragments  Touch and Camera

DateName(API level)Features Android 1.0 (API level 1)Market, Browse, Camera, Gmail, Google contacts, Maps, YouTube… Android 1.1 (API level 2)Details on Maps, Save attachments… Android 1.5 Cupcake (API level 3)Virtual Keyboards, Upload to YouTube and Picasa, Video recording in MPEG-4, Widgets, Animated transitions … …………………………………………………………………………………….. DateName(API level)Features Android 2.3–2.3.2 Gingerbread (API level 9) Design and speed, Extra large screens, SIP VoIP, enhanced copy-paste, improvements for game development, improvement in game development… …………………………………………………………………………………….. DateName(API level)Features Android 4.3 Jelly Bean (API level 18)Bluetooth 4.0, OpenGL ES 3.0, RTL languages, Developer Logging and debugging enhanced, new camera UI… Android 4.4 KitKat (API level 19)Low RAM device API, Wireless printing capability, public API for text messaging, new framework for UI transitions, built in screen recording, Bluetooth MAP support, full screen support, single pane settings app, Step Detector and Counter APIs…

     

*

 Activity  Service  Content Provider  Broadcast receiver  Intent  Manifest File  Layout  Resource  Device  Emulator  Screen size  Display density

<manifest xmlns:android= " package= "com.example.helloworld" android:versionCode= "1" android:versionName= "1.0" > <uses-sdk android:minSdkVersion= "8" android:targetSdkVersion= "17" /> <application android:allowBackup= "true" android:icon= android:label= android:theme= > <activity android:name= "com.example.helloworld.MainActivity" android:label= >

<RelativeLayout xmlns:android= " xmlns:tools= " android:layout_width= "match_parent" android:layout_height= "match_parent" android:paddingBottom= android:paddingLeft= android:paddingRight= android:paddingTop= tools:context= ".MainActivity" > <TextView android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= />

!!! adb kill-server;adb start-server !!!

/providing-resources.html#table2 -

Task: Create a Hello World application TextField: “Hello World” Add a button below the text Set the text of the button On button click change “Hello World” to “Goodbye world!” When in landscape layout, the place the button to the right of the text !!!State not saved between reorientations!!! android:configChanges= "orientation|screenSize“ application class; global variable public Object onRetainNonConfigurationInstance() getLastNonConfigurationInstance() setRetainInstance() -- Fragments

<Button android:id= android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_below= android:layout_marginTop= "75dp" android:layout_toRightOf= android:onClick= "changeText" android:typeface= "serif" android:fontFamily= "sans-serif-thin" android:background= /> <Button android:id= android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_below= android:layout_marginTop= "75dp" android:layout_toRightOf= android:onClick= "changeText“ android:background= android:textColor= android:text= />

Is default in Android 3.0 or higher (API level >= 11)

<activity … android:parentActivityName="com.example.myfirstapp.MainActivity" public void onCreate(Bundle savedInstanceState) { … getActionBar().setDisplayHomeAsUpEnabled(true); //getSupportActionBar().setDisplayHomeAsUpEnabled(true); }

<item android:id= android:orderInCategory= "100" android:showAsAction= "never" public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case: …. …. case: …. …. default: return super.onOptionsItemSelected(item); } }

@Override public void onSaveInstanceState(Bundle savedInstanceState) { // Save the user's current activity state ………………………………… // Always call the superclass so it can save the view hierarchy state super.onSaveInstanceState(savedInstanceState); public void onRestoreInstanceState(Bundle savedInstanceState) { // Always call the superclass so it can restore the view hierarchy super.onRestoreInstanceState(savedInstanceState); // Restore state members from saved instance ………………………………… }

Task 1: Add Style Create another button below the first button only for the portrait orientation Add background image and set a text color for the first button Add a background color and change the font style for the second button Task 2: Add Functionality Create another activity with only a TextView Implement the Up button Remove the settings menu Add a “Exit” menu to both activities Add “Toggle Font” menu to the new activity: Switches between Bold and Normal text in the TextView Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Intent intent = new Intent(this, com.example.helloworld.SecondActivity.class) startActivity(intent);

public class ArticleFragment extends Fragment public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.article_view, container, false); } } FragmentManager fragmentManager = getFragmentManager() FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragment fragment = new ExampleFragment(); fragmentTransaction.add(R.id.fragment_container, fragment); //fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();

Download and run FragmentExercise application Add the details fragment for the portrait orientation Change the program so you use only dynamic fragments Add a fragment to the bottom displaying the logo Add transition animation to fragments -> setCustomAnimations(int, int, int, int) FragmentTransaction transaction = getFragmentManager().beginTransaction(); getFragmentManager().findFragmentByTag("details"); transaction.replace(R.id.portraitLayout, fragment, "details");

File file = new File(context.getFilesDir(), filename); String filename = "myfile"; String string = "Hello world!"; FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(string.getBytes()); outputStream.close();

MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1); mediaPlayer.start(); Uri myUri =....; // initialize Uri here MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(getApplicationContext(), myUri); mediaPlayer.prepare(); mediaPlayer.start();

VideoView mVideoView = (VideoView)findViewById(R.id.videoview); String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k; Uri uri = Uri.parse(uriPath); mVideoView.setVideoURI(uri); mVideoView.requestFocus(); mVideoView.start(); <VideoView android:layout_width="fill_parent" android:layout_height="wrap_content" />

@Override public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: touch_start(x, y); invalidate(); break; case MotionEvent.ACTION_MOVE: touch_move(x, y); invalidate(); break; case MotionEvent.ACTION_UP: touch_up(x,y); invalidate(); break; } return true; } implements onClickListener implements onTouchListener implements onGestureListener view.setOnTouchListener …………

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { // Image captured and saved to fileUri specified in the Intent } else if (resultCode == RESULT_CANCELED) { // User cancelled the image capture } else { // Image capture failed, advise user }

Create a new Android Application that has the following functionality When the application starts it shows a splash screen (video) Then the camera starts The user takes a picture Then a game of “Whack-A-mole” starts the background is the picture previously taken every 10 seconds the user has a special skill that allows to slash. There is a message that shows when this skill is available (FRAGMENTS!!!) Every action creates a different sound (mole hit, mole missed, slashing)

Android Debug Bridge: Emulator 1, console: 5554 Emulator 1, adb: 5555 Emulator 2, console: 5556 Emulator 2, adb: 5557 adb [-d|-e|-s ] adb devices adb shell : am (activity manager), pm (package manager), screenrecord, logcat adb install; adb uninstall adb kill-server; adb start-server telnet localhost 5554: issue calls, sms,… set sensor values (Acceleration, Rotation, Magnetic-Field, …) set GPS values

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

implements LocationListener locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = public void onLocationChanged(Location location) { int lat = (int) (location.getLatitude()); int lng = (int) (location.getLongitude()); latituteField.setText(String.valueOf(lat)); longitudeField.setText(String.valueOf(lng)); protected void onResume() { super.onResume(); locationManager.requestLocationUpdates(provider, 400, 1, this); protected void onPause() { super.onPause(); locationManager.removeUpdates(this); }

implements SensorEventListener sensorManager = (SensorManager) public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { Log.d("accelerometer", "moved!"); x_acc.setText(Float.toString(event.values[0])); protected void onResume() { super.onResume(); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL); protected void onPause() { super.onPause(); locationManager.removeUpdates(this); sensorManager.unregisterListener(this); }

SDK Manager → Extras → Google Play services → add library to project keytool -list -v -alias androiddebugkey \ -keystore debug.keystore \ - storepass android -keypass android <uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_apikey" />

<fragment xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.MapFragment" /> map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); LatLng NIMES = new LatLng(43.821, 4.368) map.addMarker(new MarkerOptions().position(NIMES).title("Nimes")) map.moveCamera(CameraUpdateFactory.newLatLngZoom(NIMES, 15)) map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

Create a new Android Application that has the following functionality Uses google maps Draws a path based on where the user has traveled map.addPolyline(new PolylineOptions().add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0)).width(5).color(Color.RED)); The phone makes a sound when the user crosses an existing path The phone vibrates when the user crosses an existing path import android.os.Vibrator; Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); Create.apk file Install the apk file with the adb install command