yy1717
2020-07-23 70174da77a07dfa477dd3ff33077965edc09ff03
lib/src/main/java/com/anyun/exam/lib/SvrManager.java
@@ -7,7 +7,6 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import java.util.LinkedList;
@@ -49,9 +48,9 @@
    private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
        @Override
        public void binderDied() {
            Log.e(TAG,"IBinder.DeathRecipient binderDied");
            if (remoteInterface != null){
                Log.e(TAG,"IBinder.DeathRecipient binderDied remoteInterface != null ,return");
            MyLog.e(TAG,"IBinder.DeathRecipient binderDied");
            if (remoteInterface == null){
                MyLog.e(TAG,"IBinder.DeathRecipient binderDied remoteInterface == null ,return");
                return;
            }
            remoteInterface.asBinder().unlinkToDeath(mDeathRecipient,0);
@@ -98,7 +97,7 @@
            try {
                //设置死亡代理
                service.linkToDeath(mDeathRecipient,0);
                MyLog.i("绑定服务onServiceConnected");
                remoteInterface.registListener(RemoteCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
@@ -107,7 +106,7 @@
        @Override
        public void onServiceDisconnected(ComponentName name) {
            MyLog.i("绑定服务失败onServiceDisconnected");
        }
@@ -122,14 +121,17 @@
    public void unBindRemoteService(Context mContext){
        if (remoteInterface!=null && remoteInterface.asBinder().isBinderAlive()){
            try {
                MyLog.i("摧毁SDK,需要解绑远程回调");
                remoteInterface.unRegistListener(RemoteCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
        MyLog.i("摧毁SDK,需要解绑远程服务");
        mContext.unbindService(conn);
        if (intent!=null){
            MyLog.i("摧毁SDK,需要停止远程服务");
            mContext.stopService(intent);
        }
    }