Now, let's come to the implementation of LED Service Entity that is resided in Framework layer. For legacy architecture, the LED Service Entity is quite straightforward. The LED Service Entity code is resided in frameworks/base/service/java/com/mokoid/server/LedService.java.
Application Test Code
The test code is resided in apps/LedClient/src/com/mokoid/LedClient/LedClient.java as following:
- package com.mokoid.LedClient;
- import com.mokoid.server.LedService;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.TextView;
-
- public class LedClient extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- LedService ls = new LedService();
- ls.setOn(1);
- ls.setOff(2);
-
- TextView tv = new TextView(this);
- tv.setText("LED 1 is on. LED 2 is off.");
- setContentView(tv);
- }
- }