Android intro Building UI #1: interactions
AndroidManifest.xml permissions 2
Application Global entry point (*except ContentProvider) Per-process singleton Activity.getApplication() Service.getApplication() Context.getApplicationContext() (+cast) 3
Service Long-running off-UI tasks Runs in UI thread Must be stopped =>IntentService to the rescue! (check sources) Often used with AlarmManager for scheduled operations Might be bound to Activity lifecycle 4
BroadcastReceiver onReceive() React to some intents Broadcast to all receivers Special case – OrderedBroadcast Static in manifest or dynamic via registerReceiver/unregisterReceiver 5
Activity - extras getIntent().getXXXExtra() Bundle b = getIntent().getExtras() Bundle.getString() Bundle.putString()/putInt()/etc startActivityForResult()/onResult() 6
Activity - lifecycle onCreate()/onDestroy() (*not guaranteed) onResume()/onPause() onStart()/onStop() onConfigurationChanged() onSaveInstanceState() 7
Homework – translator app Enter word screen Results screen (with option to re-query) EditText Spinner->TextView+ListView+BaseAdapter AsyncTask! 8
AsyncTask doInBackground()/onPostExecute() onPreExecute() Not bound to lifecycle (fixed in loaders) Callback-based (don’t use.get()!) 9