Android overview
Upcoming SlideShare
Loading in...5
×
 

Android overview

on

  • 877 views

Android Framework and application building blocks

Android Framework and application building blocks

Statistics

Views

Total Views
877
Views on SlideShare
877
Embed Views
0

Actions

Likes
0
Downloads
22
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Dalvik VM Dex files Compact and efficient than class files Limited memory and battery power Core Libraries Java 5 Std edition Collections, I/O etc…

Android overview Android overview Presentation Transcript

  • Android Framework and Application Overview By: Ashish AgrawalAndroid Overview 19/12/12 1
  • Agenda  Mobile Application Development (MAD)  Introduction to Android platform  Platform architecture  Application building blocks  Lets Debug  Development tools.Android Overview 19/12/12 2
  • Introduction to Android  Open software platform for mobile development  A complete stack – OS, Middleware, Applications  Powered by Linux operating system  Fast application development in Java  Open source under the Apache 2 licenseAndroid Overview 19/12/12 3
  • Android Overview 19/12/12 4
  • Application Framework • API interface • Activity manager – manages application life cycle.Android Overview 19/12/12 5
  • Applications • Built in and user apps • Can replace built in appsAndroid Overview 19/12/12 6
  • Application Lifecycle  Application run in their own processes (VM, PID)  Processes are started and stopped as needed to run an applications components  Processes may be killed to reclaim resourcesAndroid Overview 19/12/12 7
  • Application Building Blocks  Activity  Fragments  Intents  Service (Working in the background)  Content Providers  Broadcast receivers  Action barAndroid Overview 19/12/12 8
  • Activities  Typically correspond to one UI screen  Run in the process of the .APK which installed them  But, they can:  Be faceless  Be in a floating window  Return a valueAndroid Overview 19/12/12 9
  • Android Overview 19/12/12 10
  • FragmentsFragment represents a behavior or a portion of user interface in an Activity.You can combine multiple fragments in a single activity to build a multi-paneUI and reuse a fragment in multiple activities. Android Overview 19/12/12 11
  • FragmentsAndroid Overview 19/12/12 12
  • Intents  An intent is an abstract description of an operation to be performed.  Launch an activity  Explicit Ex: Intent intent = new Intent(MyActivity.this, MyOtherActivity.class)  Implicit : Android selects the best Ex: Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(“tel: 555-2368”));  startActivity()  Extra parameter Ex: intent.putExtra(name, property);Android Overview 19/12/12 13
  • Intent Filter  Register Activities, Services, and Broadcast Receivers as being capable of performing an action on a particular kind of data.  Components that respond to broadcast ‘Intents’  Way to respond to external notification or alarms  Apps can invent and broadcast their own IntentAndroid Overview 19/12/12 14
  • Services  Faceless components that run in the background  No GUI, higher priority than inactive Activities  Usage:  responding to events, polling for data, updating Content Providers.  However, all in the main thread  E.g. music player, network download etc… Intent service = new Intent(context, WordService.class); context.startService(service);Android Overview 19/12/12 15
  • Using the Service Start the service Intent serviceIntent = new Intent(); serviceIntent.setAction ("com.wissen.testApp.service.MY_SERVICE"); startService(serviceIntent);Android Overview 19/12/12 16
  • Bind the service ServiceConnection conn = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { } @Override public void onServiceDisconnected(ComponentName arg0) { } } bindService(new Intent("com.testApp.service.MY_SERVICE"), conn, Context.BIND_AUTO_CREATE); }Android Overview 19/12/12 17
  • Async Task Asycn task enables easy and proper use of UI thread. This class allows to perform background operations and publish results on the main thread.Android Overview 19/12/12 18
  • Async Task (Example) private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> { protected Long doInBackground(URL... urls) { int count = urls.length; long totalSize = 0; for (int i = 0; i < count; i++) { totalSize += Downloader.downloadFile(urls[i]); publishProgress((int) ((i / (float) count) * 100)); } return totalSize; } protected void onProgressUpdate(Integer... progress) { setProgressPercent(progress[0]); } protected void onPostExecute(Long result) { showDialog("Downloaded " + result + " bytes"); }Android Overview } 19/12/12 19
  • ContentProviders  Enables sharing of data across applications  E.g. address book, photo gallery  Provides uniform APIs for:  querying  delete, update and insert.  Content is represented by URI and MIME typeAndroid Overview 19/12/12 20
  • Example private void displayRecords() { String columns[] = new String[] { People.NAME, People.NUMBER }; Uri mContacts = People.CONTENT_URI; Cursor cur = managedQuery(mContacts, columns, null, null, null ); if (cur.moveToFirst()) { String name = null; String phoneNo = null; do { name = cur.getString(cur.getColumnIndex(People.NAME)); phoneNo = cur.getString(cur.getColumnIndex(People.NUMBER)); } while (cur.moveToNext()); } }Android Overview 19/12/12 21
  • Broadcast Receivers A broadcast receiver is a class which extends BroadcastReceiver and which is registered as a receiver in an Android Application via the AndroidManifest.xml file(or via code). <receiver android:name="MyPhoneReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE"> </action> </intent-filter> </receiver>Android Overview 19/12/12 22
  • Broadcast Receivers public class MyBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, ”BR.”,Toast.LENGTH_LONG).show(); } }Android Overview 19/12/12 23
  • ActionBarAndroid Overview 19/12/12 24
  • ActionBar Home Icon area: The icon on the top left-hand side of the action bar is sometimes called the “Home” icon. Title area: The Title area displays the title for the action bar. Tabs area: The Tabs area is where the action bar paints the list of tabs specified. The content of this area is variable. Action Icon area: Following the Tabs area, the Action Icon area shows some of the option menu items as icons. Menu Icon area: The last area is the Menu area. It is a single standard menu icon.Android Overview 19/12/12 25
  • Debugging •Reading and Writing Logs Log.d("MyActivity”, position); •adb logcat • Toast : Toast toast = Toast.makeText(context, text, duration); toast.show();Android Overview 19/12/12 26
  • Debugging Cont. •Hierarchy Viewer •Connect your device or launch an emulator. •If you have not done so already, install the application you want to work with. •Run the application, and ensure that its UI is visible. •From a terminal, launch hierarchyviewerAndroid Overview 19/12/12 27
  • Debugging Cont. adb shell dumpsys activityAndroid Overview 19/12/12 28
  • Debugging Cont. Profiling for memoryAndroid Overview 19/12/12 29
  • Development Tools Eclipse developer.android.comAndroid Overview 19/12/12 30
  • Thank You.Android Overview 19/12/12 31