Mobile Programming Midterm Review
Agenda Layouts, widgets, toasts, and eventHandling Debuggings Resources, selections, activities, explicit intent Composite Views, activities, and implicit intent and filter Fragments, permissions, and BroadcastReceiver Dialogs, Menus, SharedPreferences. Notifications, Services, and AsyncTasks. Bound Services, location, sensors, and IntentFilters ContentProviders
Layouts Linear, Relative, Table, Tab, FrameLayout. Draw a picture based on the layout.xml
Widgets TextViews, EditText, Button, SeekBar, RadioGroup, etc. Attributes Id Layout_width Layout_height textSize inputType gravity
Toast and EvenHandling When and how to use Toast? Toast.makeText(context, “text”, Toast.LENGTH_SHORT).show(). How to handle ClickEvent.
Selections ListView What is the difference bewteen the two. Spinners How to populate the spinner Statically and dynamically ArrayAdapter setAdapter(adapter) ListView What is the difference bewteen the two. onItemSelectedListener onItemSelectedListern and onItemClickListener
Activity Activity Lifecycle The sequence of methods being called when a user starts the activity. The sequence of methods being called when the activity loses focus. Why do you need to override these lifecycle methods onPause(), onResume(), onStop(), onDestroy()
Pass Data Between Activities Bundle Check if the bundle is null! Bundle bundle = new Bundle(); bundle.putString("fname","John"); bundle.putString("lname", "Doe"); bundle.putInt("age", 18); intent.putExtras(bundle); startActivity(intent);
Explicit Intent vs Implicit Intent When do you want to use explicit intent When do you use implicit intent Intent Filters
Fragments Removing and Replacing fragments Fragments Neither a view nor activity One activity can have multiple fragments OnCreateView() returns a view. How to pass data between activity and fragment SetArguments(bundle) and getArguments() Class public member variables Removing and Replacing fragments
Permissions and BroadcastReceiver When should you use BroadcastReceivers? Override the onReceive() method How to statistically register your BroadcastReceiver? How to dynamically register your BroadcastReceiver? When do your register When do your unregister
Dialogs and Menus SharedPreference Dialogs Menu optionMenu contextMenu SharedPreference Why do you use sharedPreference How to access to your sharedPreference
Notifications What is a notification When do you use notifications?
Service What is a service? Service Lifecycle Perform a longer-running operation Running in the background The service and the UI activity share the same process Service Lifecycle onCreate(), onStartCommand(), onDestroy(), etc Service and IntentService. When do you use which?
Service Messenger is parcelable, so it can be put in a bundle. How to communicate between service and activity Broadcast Intent Pending Result (onActivityResult()) Messenger Messenger is parcelable, so it can be put in a bundle. Override handleMessage(Message msg)
Async Task Multi-threading Allows you to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. Easy the use of main UI thread Publish the result to the UI when it is needed. What is the difference between using service and Async task?
Async Task Multi-threading Allows you to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. Easy the use of main UI thread Publish the result to the UI when it is needed. What is the difference between using service and Async task?
Bound Service What is a bound service and how to use it. Ibinder Messenger
StartActivity and GetResult startActivityForResult(intent, PICK_REQUEST); protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICK_REQUEST) { if (resultCode == RESULT_OK) { /* result is OK! */ }
Midterm Exam Content provider vs sharedPreference? Permissions. When to use a content provider? ContentResolver Content provider vs sharedPreference? Permissions. Protect your content provider because By default, anyone can read from or write to your content provider. <provider> Android:readPermission=edu.tian.provider.permission.READ Android:writePermission=edu.tian.provider.permission.WRITE <permission android:name=edu.tian.provider.permission.READ>
Content Provider Short answers Debugging Development Design Given a code example, find errors and fix them Development Given a code example, complete the example. Design Extra Credits
Debugging Development Design
References The Busy Coder's Guide to Android Development - Mark Murphy Android Developers The Mobile Lab at Florida State University