0

java noob here,我只是想知道如何在一个方法中运行 2 个函数?我已经尝试过switch case,但它并没有达到我的想法......

我想包括这两个代码 -

            detachThread();
        RFBThread persistentRfbThread = this.rfbThread;
        this.rfbThread = null;
        return persistentRfbThread;

和这个-

if (_listeningDialog.isShowing() && _currentRecognizer != null)
        {
            // If a recognition is in progress, save it, because the activity
            // is about to be destroyed and recreated
            SavedState savedState = new SavedState();
            savedState.Recognizer = _currentRecognizer;
            savedState.DialogText = _listeningDialog.getText();
            savedState.DialogLevel = _listeningDialog.getLevel();
            savedState.DialogRecording = _listeningDialog.isRecording();
            savedState.Handler = _handler;

            _currentRecognizer = null; // Prevent onDestroy() from canceling
            return savedState;
        }
        return null;

在这里-

public Object onRetainNonConfigurationInstance() {

}

什么是正确的方法?

非常感谢 :)

4

1 回答 1

2
    Public Thread persistentRfbThread(){

    detachThread();
    RFBThread persistentRfbThread = this.rfbThread;
    this.rfbThread = null;
    return persistentRfbThread;
    }

and this-


       Public SavedState mystate(){
      if (_listeningDialog.isShowing() && _currentRecognizer != null)
    {
        // If a recognition is in progress, save it, because the activity
        // is about to be destroyed and recreated
        SavedState savedState = new SavedState();
        savedState.Recognizer = _currentRecognizer;
        savedState.DialogText = _listeningDialog.getText();
        savedState.DialogLevel = _listeningDialog.getLevel();
        savedState.DialogRecording = _listeningDialog.isRecording();
        savedState.Handler = _handler;

        _currentRecognizer = null; // Prevent onDestroy() from canceling
        return savedState;
    }
    return null;
    }

在这里调用这两种方法-

 public Object onRetainNonConfigurationInstance() {

//Define your condition when you require to have the data from these two function

 if(Condition 1 satisfies){

  Therad t = null;
   t = persistentRfbThread();
  }
else{
SavedState mystate;
 mystate = mystate();
  }
}
于 2013-09-06T09:35:27.843 回答