Below is the simple code fragment to illustrate the problem.
Why the value of the field "tag" logged in method "onActivityResult" not being "tag_modified"?
I also tried others async call of "startActivityForResult", but no such problem exists.
The problem merely occurs on my Moto Milestone, but everything goes well on HTC G7.
public class HelloSnapshot extends Activity {
private static Logger logger = Logger.getLogger(HelloSnapshot.class.getName());
final int REQUESTCODE_SNAPSHOT = 1;
String tag = "tag_initial";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button button = new Button(this);
button.setText("BUTTON");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tag = "tag_modified";
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUESTCODE_SNAPSHOT);
}
});
setContentView(button, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
public void onActivityResult(int requestCode, int resultCode , Intent data) {
switch (requestCode) {
case REQUESTCODE_SNAPSHOT:
if (resultCode == Activity.RESULT_OK) {
logger.info(tag);
}
break;
}
}
}