gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:45:46 26 4
gpt4 key购买 nike

这里是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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com