Android基础之内部培训
May 30, 2007 V2.0 Android Study Agenda Building Blocks Application Model UI IPC Security Q&A Building Blocks What an application would do Display UI Let user navigate from one UI to another Provide services Act due to cared events Store, retrieve, share data What does android provide Activity Service Intents Broadcast Receiver Notification Content Provider Manifest file Activity What does an activity do ? Display A single screen of your application Respond for events How to move to another screen ? start a new activity How is the previous screen(activity) ? Paused and put onto a history stack History stack Android retains history stacks for each application launched from the home screen. Allow user to navigate through screens back and forth smoothly Activity key methods public void startActivity(Intent intent); protected void onCreate(Bundle savedInstanceState); //restart and restore activity to previous state here protected void onStart(); protected void onResume(); protected void onPause(); //persistent data should be write here protected void onStop(); protected void onDestroy(); protected void onSaveInstanceState(Bundle outState); Activity lifecycle Entire lifecycle onCreate onDestroy Visible lifecycle onStart onStop Foreground lifecycle onResume onPause Service What is service Code that is long-lived and runs without a UI E.g. playing music in the background How to start a service Start service Bind service (RPC) Intent A request to do something ACTION_VIEW content://contacts/1 -- Display information about the person whose identifier is "1". ACTION_DIAL content://contacts/1 -- Display the phone dialer with the person filled in. ACTION_EDIT content://contacts/1 -- Edit information about the person whose identifier is "1". Typically used as inputs for below methods startActivity sendBroadcast startService bindService Intent resolution “Apps are equal” Any app on the mobile device can be replaced or extended -- even core componMay 30, 2007 V2.0 Android