Android System Service how-to



//Add library that application can link against


<library name="android.awt"  file="/system/framework/android.awt.jar" />
Modify services/java/com/android/server/
@Modify ServerThread:run method, adding our service to ServiceManager
try {
Log.i(TAG, “Starting Your Service.");
ServiceManager.addService(Context.YOUR_SERVICE, new YourService(context));
} catch (Throwable e) {
Log.e(TAG, “Failure starting Your Service", e);
Modify  core/java/android/content/
@add service constant string to context class
public static final String WIMAX_SERVICE = “wimax";
Modify core/java/android/app/
@add class field to contain your service
private static YourManager sYourManager;
@change getSystemService ( ) method to return your service instance
if (YOUR_SERVICE.equals(name)) {
return getYourManager();
@add class method to retrieve IBinder stub from ServiceManager
private YourManager getYourManager()
synchronized (sSync) {
if (sYourManager == null) {
IBinder b = ServiceManager.getService(YOUR_SERVICE);
IYourManager service = IYourManager.Stub.asInterface(b);
sYourManager = new YourManager(service, mMainThread.getHandler());
return sYourManager;
Update current.xml by execute following commands
make update-api


在下方填入你的資料或按右方圖示以社群網站登入: Logo

您的留言將使用 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )


您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: