Skip to content

Commit 8b01c66

Browse files
committed
Update MainActivity.java
1 parent 1ba2660 commit 8b01c66

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Uploading/app/src/main/java/com/tss/uploading/MainActivity.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,31 @@ private void imageChooser()
8282
catch (IOException e) {
8383
e.printStackTrace();
8484
}
85-
imageView.setImageBitmap(
85+
IVPreviewImage.setImageBitmap(
8686
selectedImageBitmap);
8787
}
8888
}
8989
});
9090

91+
// this function is triggered when user
92+
// selects the image from the imageChooser
93+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
94+
super.onActivityResult(requestCode, resultCode, data);
95+
96+
if (resultCode == RESULT_OK) {
97+
98+
// compare the resultCode with the
99+
// SELECT_PICTURE constant
100+
if (requestCode == SELECT_PICTURE) {
101+
// Get the url of the image from data
102+
Uri selectedImageUri = data.getData();
103+
if (null != selectedImageUri) {
104+
// update the preview image in the layout
105+
IVPreviewImage.setImageURI(selectedImageUri);
106+
}
107+
}
108+
}
109+
}
91110
}
92111

93112

0 commit comments

Comments
 (0)