Reputation: 1116
I have two method saveLesson()
and uploadFile()
which takes some time to finish.
I'd like for the second method must start only after the first one finish.
saveLesson();
if (!lessonDetails.get("file").matches(";No file attached")) {
ArrayList<String> allFileUris = getFileNames(lessonDetails.get("file"));
uploadFile(allFileUris);
}
Upvotes: 1
Views: 20936
Reputation: 4082
This could be one way to suit some needs
boolean firstFunctionResult = firstFunction("1");
Second Function
if (firstFunctionResult) {
Toast.makeText(mContext,
"Dance",
Toast.LENGTH_SHORT).show();
// Can Run Some Function Here
}
First Function
public boolean firstFunction(String variableToCheck) {
if (variableToCheck=="1") {
return true;
} else {
return false;
}
}
One is tempted to test a way with OnActivityResult - but one fears it will not be reusable..
Upvotes: 0
Reputation: 2494
you can take below approaches for the same
1) you can call second method from first method itself in the last of first method.
2) You can create a Asynctask and execute first method and after the first method is executed then onPostExecute method call another method
Upvotes: 8