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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

690件の閲覧回数
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 返信

571件の閲覧回数
daiane_angolini
NXP Employee
NXP Employee
Great, thanks for sharing.
0 件の賞賛
返信