Brief Information
- Name : Operating System 운영체제
- Lecturer : Ahn Woohyun 안우현
- Semester : 2016 Fall
- Major?: BE,?Computer Science and Engineering
- Textbook
- Syllabus : Syllabus_2016-5-2__Embedded Operating System.pdf
- In?short
- Programming Android programs
- Review the Tests
- Midterm:
- Know the code routine for a certain function.
- Know definitions and lists.
- Coding experience would help me exclusive to others. Most difficult are the problems that require us to fill in blanks in some source codes.
- Midterm:
Assignments
Assignment 1
- Title: Display like the given layout
- Duration: 2016-09-07~11 (4 days)
- Key words: layout XML files, LinearLayout, RelavtiveLayout, TextView, EditText, Button
- Demonstration video
- Project files
Assignment 2
- Title: Implementing a calculator
- Duration: 2016-09-21~28 (7 days)
- Keywords: TableLayout, Button, RadioButton
- Demonstration video
- Project files
Assignment 3
- Title: Implicit intent with WebView, TextView, and a hyperlink
- Duration: 2016-10-12~26 (14 days)
- Key words:?Intent, implicit intent, WebView
- Demonstration video
- Project files
Assignment 4
- Title: Display the air quality in Seoul depending on the input date and place
- Duration: 2016-10-28~11-13 (16 days)
- Key words: Intent, XML parsing, DOM parser, working thread
- Demonstration video
- Project files
Assignment 5
- Title: Music Player
- Duration: 2016-?-?~12-21
- Key words
- Demonstration video
- Project files
How to Study
- Know how to use classes.
- Know terms in Android.
- Remember example implementations.
Summary
4 Components in Android
- Activities
- Broadcast receivers
- Content providers
- Services
Chapter 4. The Concept of Views and View Groups
Chapter 5. View Groups
Types of View Groups
- LinearLayout
- RelativeLayout
- FrameLayout
- TableLayout
Chapter 6. Views
Types of Views
- TextView
- EditText
- Button
- ImageView
Chapter 8. Events
Types of Events
- TouchEvent
- KeyEvent
Focus
Chapter 10. Execution of an Activity and Intent
Chapter 11. Activity Lifecycle
Chapter 13.?Data Communication Using Intent
Chapter 14-1. Processes and Threads
Chapter 14-2. Looper, MessageQueue, and Handler
Chapter 14-3.?AsyncTask, CountDownTimer, Timer, and HandlerThread
AsyncTask
- doInBackground() is executed by a?working thread. The rest of methods are executed by the UI thread.
- doInBackground() should always be implemented.
Steps to Implement AsyncTask
- Make an Activity.
- In the Activity, public
Chapter 15. BroadcastReceiver and BroadcastListener
- Classes
- BroadcastReceiver
- onReceive(Context, Intent)
- Activity
- sendBroadcast(Intent)
- registerReceiver(BroadcastReceiver, IntentFilter)
- unregisterReceiver(BroadcastReceiver)
- BroadcastReceiver
- Concepts
- broadcast & receive
- static broadcast receivers & dynamic broadcast receivers
Broadcasting Activities
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0" encoding="utf-8"?> <manifest> <application> <activity> android:name="com.superdroid.test.Broadcasting.BroadcastingActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public class BroadcastingActivity extends Activity { ... public void onClick(View v) { Intent intent = new Intent(); intent.setAction("com.superdroid.test.Broadcasting.action.FILE_DOWNLOADED"); intent.putExtra("FILE_NAME", "superdroid.png"); // intent.putFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); // all receivers will be executed. // intent.putFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); // Only dynamic BroadcastReceivers // intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); // No same type broadcasts // intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); // High priority broadcastReceivers sendBroadcast(intent); } } |
Static Broadcast Receivers
- Register a broadcast receiver before the compile time.
- AndroidManifest.xml>>application tag>> Add receiver tag
1234567<application>...<receiver android:name=".BroadcastSideReceiver"><intent-filter android:priority="0"><action android:name="com.superdroid.test.Broadcasting.action.FILE_DOWNLOAD"></intent-filter></receiver></application>
Dynamic Broadcast Receivers
- Register a broadcast receiver in the running time.
- Register a broadcast receiver.
123456789101112131415public class BroadcastingActivity extends Activity {BroadcastReceiver broadcastReceiver = null;protected void onCreate(Bundle savedInstanceState) {...IntentFilter intentFilter = new IntentFilter();intentFilter.addAction("com.superdroid.test.Broadcasting.action.FILE_DOWNLOADED");intentFilter.setPriority(0); // Higher, earlier.broadcastReceiver = new BroadcastReceiver() {public void onReceive(Context context, Intent intent) {String fileName = intent.getStringExtra("FILE_NAME");}registerReceiver(broadcastReceiver, intentFilter);}}} - Unregister the broadcast receiver.
123456789public class BroadcastingActivity extends Activity {BroadcastReceiver broadcastReceiver = null;...protected void onDestroy() {unregisterReceiver(broadcastReceiver);super.onDestroy();}...}
FLAG_EXCLUDE_STOPPED_PACKAGES Intent Filter
- FLAG_EXCLUDE_STOPPED_PACKAGES
- The default state
- If set, this intent will not match any components in packages that are currently stopped.
- FLAG_INCLUDE_STOPPED_PACKAGES
- If set, this intent will always match any components in packages that are currently stopped.
-
12345Intent intent = new Intent();intent.setAction(...);intent.putExtra(...);intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);sentBroadcast(intent);
Chapter 18. Services
- There are two modes of services: started services and bound services.
- Started services
- start/end a service
- Other components can start a started service.
- Other components can end a started service.
- Bound services
- between the start and end of a service
- If a service is on running, a bound service can return the requested result.
- connection
- Since Service is one of the 4 components, after a Service is made, the Service should be added in <application> tag in AndroidManifest.xml.
Chapter 16. Files and Databases
Chapter 17. Content Providers
Chapter 20. Advanced View Groups
ScrollView
- 뷰마다 배치가 다양한 레이아웃을 스크롤하고 싶다면 스크롤뷰를 사용한다.
- 스크롤 전에 보이지 않을 자식뷰까지 미리 그려두기 때문에 자식 뷰가 많을수록 메모리 사용량이 증가.
AdapterView
- 동일한 구조의 레이아웃들이 수직으로 그룹을 구성한 리스트의 구조.
- 현재 화면에 보이지 않는 자식 뷰를 미리 생성하지 않고 스크롤되어 보여야할 때 비로소 생성된다. 메모리 사용량 감소.