我整天搜索这个问题:
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) {
答案 0 :(得分:1)