From dd7c608db87a478e22d7138e9631e98033022e66 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期三, 05 六月 2019 14:22:41 +0800 Subject: [PATCH] RemoteService aidl 回调搭架子;app依赖lib --- lib/src/main/java/com/anyun/exam/lib/RemoteService.java | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java index f69e568..1982465 100644 --- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java +++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java @@ -3,7 +3,10 @@ import android.app.Service; import android.content.Intent; import android.os.IBinder; +import android.os.RemoteCallbackList; +import android.os.RemoteException; import android.support.annotation.Nullable; +import android.util.Log; /** * MyApplication2 @@ -12,9 +15,43 @@ * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class RemoteService extends Service { + + private static final String TAG = "RemoteService"; + private RemoteCallbackList<IListenerInterface> mListenerList = new RemoteCallbackList(); + private IRemoteInterface.Stub iRemoteInterface = new IRemoteInterface.Stub(){ + @Override + public void registListener(IListenerInterface i) throws RemoteException { + //娉ㄥ唽鍥炶皟鏂规硶 + mListenerList.register(i); + } + + @Override + public void unRegistListener(IListenerInterface i) throws RemoteException { + mListenerList.unregister(i); + } + + @Override + public void add() throws RemoteException { + + } + + + }; @Nullable @Override public IBinder onBind(Intent intent) { - return null; + return iRemoteInterface; + } + + @Override + public void onCreate() { + super.onCreate(); + Log.i(TAG,"onCreate()"); + } + + @Override + public void onDestroy() { + super.onDestroy(); + Log.i(TAG,"onDestroy"); } } -- Gitblit v1.8.0