Differences

This shows you the differences between two versions of the page.

Link to this comparison view

osp:lectures:lecture-services [2016/10/05 11:59]
laura.gheorghe
osp:lectures:lecture-services [2016/11/06 18:55] (current)
laura.gheorghe [Lecture]
Line 9: Line 9:
  
   *{{:​osp:​lectures:​lecture-services.pdf | Lecture Slides}}   *{{:​osp:​lectures:​lecture-services.pdf | Lecture Slides}}
 +  *{{:​osp:​lectures:​4.services_notes.pdf | Lecture Notes}}
  
 {{url>​http://​ocw.cs.pub.ro/​courses/​_media/​osp/​lectures/​lecture-services.pdf}} {{url>​http://​ocw.cs.pub.ro/​courses/​_media/​osp/​lectures/​lecture-services.pdf}}
Line 23: Line 24:
   * {{osp:​media:​lab3.zip|}}   * {{osp:​media:​lab3.zip|}}
  
-=== Task 1 - Creating a started service ===+=== Task 1 - Creating a started service ​(3p) ===
  
 Create a new project with a blank main Activity. Add an EditText, a Button and a TextView to the Activity'​s layout. From the lab files, add the ''​PiComputer.java''​ class to your project. This class computes the number ''​PI''​ with variable precisions using the [[https://​en.wikipedia.org/​wiki/​Vi%C3%A8te%27s_formula|Viete series]]. Your first task is to create a started service that will receive a value for the precision, will create an instance of the ''​PiComputer''​ class giving it the received precision value and call the ''​compute()''​ method, retrieving the result. ​ Create a new project with a blank main Activity. Add an EditText, a Button and a TextView to the Activity'​s layout. From the lab files, add the ''​PiComputer.java''​ class to your project. This class computes the number ''​PI''​ with variable precisions using the [[https://​en.wikipedia.org/​wiki/​Vi%C3%A8te%27s_formula|Viete series]]. Your first task is to create a started service that will receive a value for the precision, will create an instance of the ''​PiComputer''​ class giving it the received precision value and call the ''​compute()''​ method, retrieving the result. ​
Line 86: Line 87:
 sendBroadcast(i);​ sendBroadcast(i);​
 </​code>​ </​code>​
-=== Task 2 - Running a foreground service ===+=== Task 2 - Running a foreground service ​(3p) ===
  
 We want to have a new service notifying the user that our application is online, providing with a always-present notification which can be used to access the app at any time. We want to have a new service notifying the user that our application is online, providing with a always-present notification which can be used to access the app at any time.
Line 120: Line 121:
  
  
-=== Task 3 - Moving from started service to bounded service ===+=== Task 3 - Moving from started service to bounded service ​(4p) ===
  
 We now want to compute the value of ''​PI''​ using a bounded service instead of a started one. Therefore, create a third service and add it to the ''​AndroidManifest.xml''​. Within this service'​s class declare an inner class that extends ''​Binder''​. Add a method to the class that returns the current instance of the service class: We now want to compute the value of ''​PI''​ using a bounded service instead of a started one. Therefore, create a third service and add it to the ''​AndroidManifest.xml''​. Within this service'​s class declare an inner class that extends ''​Binder''​. Add a method to the class that returns the current instance of the service class:
Line 202: Line 203:
 </​code>​ </​code>​
  
-=== Bonus: Task 4 - Connecting to a bounded service from another application ===+=== Bonus: Task 4 - Connecting to a bounded service from another application ​(4p) ===
  
 We now want to make a fourth service that will expose the ''​PiComputer''​ mechanism to external applications. Create a ''​IExtService.aidl''​ file in the ''​src/''​ folder of your application,​ within the same package as all other services. Within the ''​.aidl''​ file we will declare an interface which will be used by the system to allow external applications access to our internal service'​s functionality:​ We now want to make a fourth service that will expose the ''​PiComputer''​ mechanism to external applications. Create a ''​IExtService.aidl''​ file in the ''​src/''​ folder of your application,​ within the same package as all other services. Within the ''​.aidl''​ file we will declare an interface which will be used by the system to allow external applications access to our internal service'​s functionality:​
osp/lectures/lecture-services.1475657963.txt.gz ยท Last modified: 2016/10/05 11:59 by laura.gheorghe
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0