I know this has answers here and there, but I couldn't make any of them work. Does anybody know a good reference, or a tutorial for this, maybe also post here?
What I need to do is :
1) provide a button, that opens the camera application. I have done this by a startResultActivity()
2) user takes the photo, and returns to the application, with the photo saved, preferably with a preview in an ImageView. I tried something, but I cannot test in an emulated device.
3) presses a "send" button, and the application sends the picture to HTTP POST. With "multipart", whatever that is. The php developer does not want me to send the picture as a string converted from a bitmap array.
Any help for this will be appreciated. Thanks !
This link should be more than sufficient for clicking, saving and getting path of an image: Capture Images
This is the class i wrote for uploading images via HTTP POST:
Usage is quite simple: call this static method and pass the path of your image like:
and finally:
and don't forget to call this function in a separate thread or you'll get NetworkOnMainThreadException.. :)
Update
I'd recommend not to reinvent the wheel & use OkHttp instead. Do checkout the Recipes page. Disclaimer: I'm not a contributor to the project, but I love it. Thanks to Square team.