You might give this a try:
if (getParent() == null) {
setResult(RESULT_OK, dataTobePassback);
} else {
getParent().setResult(RESULT_OK, dataTobePassback);
}
dataTobePassback
is an Intent
that carries the stuff you may need to pass back to the calling activity