yy1717
2020-01-06 9c13ff18dab0c35ada32a318ab6e380c9b184ffe
lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -11,6 +11,7 @@
import com.anyun.exam.lib.util.DESUtil;
import com.anyun.exam.lib.util.NetUtils;
import com.anyun.exam.lib.util.Speaker;
import androidx.annotation.Nullable;
@@ -30,6 +31,8 @@
    private RemoteCallbackList<IListenerInterface> mListenerList = new RemoteCallbackList();
    private IListenerInterface mListener;
    private int msgId = 0;
    private Speaker speaker = null;
    private IRemoteInterface.Stub iRemoteInterface = new IRemoteInterface.Stub(){
        @Override
        public void registListener(IListenerInterface i) throws RemoteException {
@@ -59,6 +62,8 @@
    public void onCreate() {
        super.onCreate();
        Log.i(TAG,"onCreate()");
        speaker = new Speaker(getApplicationContext());
        startNative();
        new Thread(new Worker()).start();
    }
@@ -69,7 +74,7 @@
        public void run() {
            while (!mIsServiceDestroyed.get()){
                try {
                    Thread.sleep(4*1000);
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
@@ -88,8 +93,12 @@
    private void onMessageArrived(String json){
        int N = mListenerList.getRegisteredCallbackCount();
        Log.d(TAG, "getRegisteredCallbackCount = " + N);
        mListenerList.beginBroadcast();
        for (int i = 0; i < N; i++) {
            mListenerList.beginBroadcast();
            mListener  = mListenerList.getBroadcastItem(i);
            if (mListener != null){
                try {
@@ -98,8 +107,9 @@
                    e.printStackTrace();
                }
            }
            mListenerList.finishBroadcast();
        }
        mListenerList.finishBroadcast();
    }
    public String javaGetImei() {
@@ -163,9 +173,9 @@
    }
    public void TextSpeak(String text) {
/*        if (speaker != null) {
        if (speaker != null) {
            speaker.speak(text);
        }*/
        }
    }
    // Used to load the 'native-lib' library on application startup.