Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.

Similar presentations


Presentation on theme: "Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton."— Presentation transcript:

1 Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton

2 Android Layered Architecture

3 App Components Activities Activities –A single screen with a user interface –An app may contain many activities –Ex.: a display of contacts Services Services –Components that run in background –No user interface –Ex. Access remote database Content Providers Content Providers –Components that manage shared data among apps –Files, SQLite, the internet –Ex.: contacts Broadcast Receivers Broadcast Receivers –Components that are registered to respond to system events –Ex.: battery low

4 Activity Life Cycle

5 Activity Responds to State changes public class ExampleActivity extends Activity { public void onCreate(Bundle savedInstanceState) protected void onStart() protected void onResume() protected void onPause() protected void onStop() protected void onDestroy() }

6 Transition between Activities Activity can explicitly start another activity in the same or a different app explicitly - explicit Intent Activity can explicitly start another activity in the same or a different app explicitly - explicit Intent Activity can ask the system to find an activity to can do the expected work – implicit Intent Activity can ask the system to find an activity to can do the expected work – implicit Intent Intent is like an event bus, listeners (Activities) can register with the system what functions they can perform using Intent-Filter Intent is like an event bus, listeners (Activities) can register with the system what functions they can perform using Intent-Filter

7 Intent Bus Activity A Intent Filter Activity C Activity B Activity D Activity B Intent X Intent Y to C App X App Y Activity A wants to find an activity that can handle Intent X. The Activity Manager finds Activities that have registered to handle the intent. A invokes D.

8 Explicit Intent Intent explicitIntent = new Intent(InvokingActicity.this, InvokedActivity.class); InvokedActivity.class);StartActivity(explicitIntent); // this is normally used to start another activity in the same application // the invoked activity does not need to specify its Intent_filter.

9 Implicit Intent Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(“http://www.google.com”)); Uri.parse(“http://www.google.com”));“http://www.google.com”) StartActivity(webIntent); // the activity manager will find an activity that is capable of browsing // if there are more than activity capable of VIEW, the user will be asked to choose.

10 Intent Filter

11 Inter-activity Communications An activity may user intent to transfer data to the invoked activity An activity may user intent to transfer data to the invoked activity An activity may ask another activity to return result – as an asynchronous call. An activity may ask another activity to return result – as an asynchronous call. An activity shares a content provider with the other activity in the same app An activity shares a content provider with the other activity in the same app An activity share Preferences with another activity in the same app. An activity share Preferences with another activity in the same app.

12 Processes and Threads Each app is a process Each app is a process Each process is in its own sandbox Each process is in its own sandbox Each process may have many threads. Each process may have many threads. Each process has only one UI thread Each process has only one UI thread UI thread handles all UIs UI thread handles all UIs

13 AsyncTask onPreExecute :AsyncTask UI threadWorker thread onPostxecute doInBackground execute

14 MVP: Model-View-Presenter Event Bus View Define GUI (textfields, buttons, etc) Presenter Control and response to user actions Model Maintain business logic and entities View Presenter

15 MVP Support in Android Event Bus View -> XML file XML file specifies GUI Presenter -> Activity Control the GUI Model –> Business + Content Provider Your classes + SQLite DB/Files/Intent View Presenter

16 Security Architecture Each app has a unique user id Each app has a unique user id Each app is executed as a process under that user id Each app is executed as a process under that user id Each app is run in its now sandbox Each app is run in its now sandbox Each app must declare any resources outside the sandbox Each app must declare any resources outside the sandbox At app install time, the user can either grant or deny the permissions. At app install time, the user can either grant or deny the permissions.

17 Apps – Processes - Threads App B App A UI Thread Service Thread Worker Thread UI Thread Sandbox for App A Firewall by the OS Sandbox

18 Protected Resources Camera functions Camera functions Location data (GPS) Location data (GPS) Bluetooth functions Bluetooth functions Telephony functions Telephony functions SMS/MMS functions SMS/MMS functions Network/data connections Network/data connections

19 Android Permissions About 120 android-defined permissions About 120 android-defined permissions Any app wants to access any resource such as contacts must declare the permissions Any app wants to access any resource such as contacts must declare the permissions Permissions are declared in AndroidManifest.xml using tags. Permissions are declared in AndroidManifest.xml using tags. An app trying to access a protected resource without needed permissions will get SecurityException An app trying to access a protected resource without needed permissions will get SecurityException

20 Android Permissions An app can define a permission who may start the app An app can define a permission who may start the app An activity can define a permission who may start the activity An activity can define a permission who may start the activity A service can define a permission who may bind/start the service A service can define a permission who may bind/start the service A contentProvider can restrict who may access the data in the contentProvider A contentProvider can restrict who may access the data in the contentProvider

21 Android Permissions A broadcast receiver can define a permission who may sent an event to it A broadcast receiver can define a permission who may sent an event to it A broadcast sender can define a permission who may receive the broadcast. A broadcast sender can define a permission who may receive the broadcast.

22 Questions???


Download ppt "Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton."

Similar presentations


Ads by Google