| | |
| | | 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 |
| | |
| | | * 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"); |
| | | } |
| | | } |