我编写了这段代码来从计算器返回值:
try {
startActivity(intent);
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
// User pressed OK.
double value = data.getDoubleExtra("X", Double.NaN);
if (Double.isNaN(value)) {
// Calculation result was "Error".
} else {
// Calculation result ok.
}
} else {
// User pressed cancel or back button.
}
}
}
它给了我一行中括号、逗号和单词 Intent 的语法错误:
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
一些为什么它需要分号而不是所有这些符号。你知道为什么吗?