Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android webinar class_4


Published on

  • Be the first to comment

Android webinar class_4

  1. 1. Storing Information on the device
  2. 2. Internal Storage on the device• You can save files directly on the devices internal storage• By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user).• When the user uninstalls your application, these files are removed.
  3. 3. Usage:• Call openFileOutput() with the name of the file and the operating mode. This returns aFileOutputStream• Write to the file with write()• Close the stream with close()
  4. 4. External Storage• Every Android-compatible device supports a shared "external storage" that you can use to save files• Files saved to the external storage are world-readable and can be modified by the user
  5. 5. Usage:• Checking media availability :Using getExternalStorageState()• If youre using API Level 8 or greater, use getExternalCacheDir() to open a File• If youre using API Level 7 or lower, use getExternalStorageDirectory() to open a File
  6. 6. Finding the File:
  7. 7. Animation in Android
  8. 8. Animation• There are two types of animations that you can do with the Animation framework of Android.• Class - android.view.animation.Animation1. Frame animation2. Tween animation
  9. 9. Frame animation• A series of frames is drawn one after the other at regular .• Frame-by-frame animation is handled by the AnimationDrawable class.
  10. 10. android_frame_anim.xml<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android=""android:oneshot="false"><item android:drawable="@drawable/android_1" android:duration="100" /><item android:drawable="@drawable/android_2" android:duration="100" /><item android:drawable="@drawable/android_3" android:duration="100" /><item android:drawable="@drawable/android_4" android:duration="100" /><item android:drawable="@drawable/android_5" android:duration="100" /><item android:drawable="@drawable/android_6" android:duration="100" /><item android:drawable="@drawable/android_7" android:duration="100" /></animation-list>
  11. 11. Tween animation• Simple transformations of position, size, rotation etc. to the content of a View.• Animation can be defined in XML that performs transitions such as rotating, fading, moving, and stretching on a graphic.• If you want to perform more than one Animation you can define in a <set>.• <set> is a container that can holds other animation elements like - <alpha>,<scale>, <translate>,<rotate> or other <set>
  12. 12. <alpha>• A fade-in or fade-out animation• Attributes:• android:fromAlpha – Float value. Starting opacity offset.• android:toAlpha – Float value. Ending opacity offset• Where 0.0 is transparent and 1.0 is opaque.
  13. 13. <scale>• A resizing animation represents ScaleAnimation.• You can specify the center point of the image from which it grows outward (or inward) by specifying pivotX and pivotY.• <scale android:fromXScale="float" android:toXScale="float" android:fromYScale="float" android:toYScale="float" android:pivotX="float" android:pivotY="float" />
  14. 14. <translate>• A vertical and/or horizontal motion represents TranslateAnimation. – values from -100 to 100 ending with "%", indicating a percentage relative to itself; – values from -100 to 100 ending in "%p", indicating a percentage relative to its parent; – a float value with no suffix, indicating an absolute value.• <translate android:fromXDelta="float" android:toXDelta="float" android:fromYDelta="float" android:toYDelta="float" />
  15. 15. <rotate>• A rotation animation represents a RotateAnimation.• pivotX and pivotY will define the center point of rotation.• <rotate android:fromDegrees="float“ android:toDegrees="float" android:pivotX="float" android:pivotY="float" />
  16. 16. Async Task
  17. 17. AsyncTask• AsyncTask class encapsulates the creation of Threads and Handlers.• AsyncTask is started via the execute() method.• The execute() method calls the doInBackground() and onPostExecute() method.• The doInBackground() method contains the coding instruction which should be performed in a background (separate) thread.• The onPostExecute() method updates the UI Thread once the doInBackground() method finishes.
  18. 18. AsyncTask• AsyncTask<Params, Progress, Result>• The three types used by an asynchronous task are the following: – Params, the type of the parameters sent to the task upon execution. – Progress, the type of the progress units published during the background computation. – Result, the type of the result of the background computation.
  19. 19. AsyncTask Coding Samplepublic class Sample extends AsyncTask<String, String , String>{ @Override protected void onProgressUpdate(String... values) { super.onProgressUpdate(values); } @Override protected String doInBackground(String... params) { return null; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); }}
  20. 20. Canvas
  21. 21. Canvas• The Canvas class holds the "draw" calls.• To draw something, you need 4 basic components: – A Bitmap to hold the pixels – A Canvas to host the draw calls (writing into the bitmap) – a drawing primitive (e.g. Rect, Path, text, Bitmap) – and a paint (to describe the colors and styles for the drawing)
  22. 22. Paint and Path
  23. 23. Paint• The Paint object represents the "brush".• Views draw themself in the onDraw() method.• Canvas object allows you to perform drawing operations on it, e.g. draw lines, circle, text and Bitmaps.• Invalidate(); method forces a view to draw.• Because of invalidate(); onDraw method is called.
  24. 24. PropertiesPaint Object Property Descriptionpaint.setAntiAlias(true); Makes the edges smooth.paint.setColor(Color.RED); Set the paints color.paint.setStyle(Paint.Style.STROKE); Set the paints style, It controls primitive geometrypaint.setStrokeJoin(Paint.Join.ROUND); Sets the paint’s join.paint.setStrokeWidth(15f); Set the width for stroking.Touch Event DescriptionMotionEvent.ACTION_DOWN When you touch the screenMotionEvent.ACTION_MOVE When you move your finger across the screenMotionEvent.ACTION_UP When you remove your finger from the screen
  25. 25. Process for Project Submission & Evaluation• Each student is expected to create an Android App as Project Work for the Course.• Certificates will be provided to the students after project submission and evaluation• At the time of project submission a skype interview will be conducted.• The project will be evaluated on Usability, Functionality and Design.• We are always there to help you on forum and on skype.
  26. 26. Project Plan Week 4 + Week 5 Week 6
  27. 27. Evaluation Process 10 Days Interviews Awards Certificates Evaluation 7 Days And Submission
  28. 28. •Q & A..?