package com.anyun.exam.lib; 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 * Created by lzw on 2019/6/5. 13:22:46 * 邮箱:632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class RemoteService extends Service { private static final String TAG = "RemoteService"; private RemoteCallbackList 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 iRemoteInterface; } @Override public void onCreate() { super.onCreate(); Log.i(TAG,"onCreate()"); } @Override public void onDestroy() { super.onDestroy(); Log.i(TAG,"onDestroy"); } }