现在的位置: 首页 > 综合 > 正文

android的HAL第二种调用hal方法中的SystemServer (属于APP层)代码的实现:

2013年10月30日 ⁄ 综合 ⁄ 共 955字 ⁄ 字号 评论关闭

 

2)SystemServer (属于APP层)
文件:mokoid-read-only/apps/LedTest/src/com/mokoid/LedTest/LedSystemServer.java
 

view plaincopy to clipboardprint?
package com.mokoid.LedTest;  
import com.mokoid.server.LedService;  
import android.os.IBinder;  
import android.os.ServiceManager;  
import android.util.Log;  
import android.app.Service;  
import android.content.Context;  
import android.content.Intent;  
  
public class LedSystemServer extends Service {  
//注意这里的Service是APP中的概念,代表一个后台进程。注意区别和Framework中的service的概念。 
 @Override  
    public IBinder onBind(Intent intent) {  
        return null;  
    public void onStart(Intent intent, int startId) {  
        Log.i("LedSystemServer", "Start LedService...");  
  
    /* Please also see SystemServer.java for your interests. */  
    LedService ls = new LedService();  
        try {  
            ServiceManager.addService("led", ls);  //将LedService添加到ServiceManager中  

        } catch (RuntimeException e) {  
            Log.e("LedSystemServer", "Start LedService failed.");  
        }  
    }  
}  
 

抱歉!评论已关闭.