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