我整天搜索这个问题:
mUploadImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(
Intent.createChooser(intent, "Select a Picture"),
FILE_SELECT_CODE);
}
});
每当我单击 mUploadImage OnActivityResult() 方法时,它将立即被触发(尽管我还没有选择任何文件)并且结果代码始终为 0。有人可以帮助我吗?
编辑:(来自下面的评论)
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
if (arg0 == FILE_SELECT_CODE) {
Log.v(TAG, "Selected a image. Result code: " + arg1);
if (arg1 == Activity.RESULT_OK) {