java - 2 在java中的方法中可执行

标签 java android methods

这里是java菜鸟,我只是想知道如何在一个方法中运行两个函数?我尝试过 switch case,但它没有达到我的预期...

我想包含这 2 个代码 -

            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() {

}

正确的做法是什么?

非常感谢:)

最佳答案

    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();
  }
}

关于java - 2 在java中的方法中可执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18654401/

相关文章:

android - Android 中的位置提供者?

methods - IBM Rational Rose : Is it possible to model class's operations and integrate it for code generation?

android - 电容 Android 插件由于某种原因无法工作

android - 将相册添加到 Android 照片库(在代码中)

java - getBetween 特定页面上的两个字符串?

java - 方法的重复

Java Swing : Access panel components from another class

java - 为什么字节参数不被识别为整数?

java - 返回 null 的构造函数的替代方案

java - Android的OCR应用程序