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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

955 次查看
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. }
标记 (1)
0 项奖励
回复
1 回复

836 次查看
daiane_angolini
NXP Employee
NXP Employee
Great, thanks for sharing.
0 项奖励
回复