Integrate a new hardware into Android (3) -blog archive

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Integrate a new hardware into Android (3) -blog archive

529 Views
AlanZhang
Contributor V

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.

106-LegacyService.png

 

 

Application Test Code

The test code is resided in apps/LedClient/src/com/mokoid/LedClient/LedClient.java as following:

  1. package com.mokoid.LedClient;  
  2. import com.mokoid.server.LedService;  // Import LedService in FrameWork layer
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.widget.TextView;  
  6.   
  7. public class LedClient extends Activity {  
  8.     @Override  
  9.     public void onCreate(Bundle savedInstanceState) {  
  10.         super.onCreate(savedInstanceState);  
  11.         // Call an API on the library.  
  12.     LedService ls = new LedService();  // Instantiate LedService  
  13.     ls.setOn(1);                       // via public methods to control low level hardware 
  14.     ls.setOff(2);  
  15.           
  16.         TextView tv = new TextView(this);  
  17.         tv.setText("LED 1 is on. LED 2 is off.");  
  18.         setContentView(tv);  
  19.     }  
  20. }
Tags (1)
0 Kudos
1 Reply

410 Views
daiane_angolini
NXP Employee
NXP Employee
Great, thanks for sharing.
0 Kudos