在android中发送图像到URL
以下是我在捕获图像后用于从应用程序中的相机捕获图像的代码
public void startCamera()
{
Log.d("ANDRO_CAMERA", "Starting camera on the phone...");
String fileName = "testphoto.jpg";
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, IMAGE_CAPTURE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_CAPTURE)
{
if (resultCode == RESULT_OK)
{
Log.d("ANDRO_CAMERA","Picture taken!!!");
imageView.setImageURI(imageUri);
}
}
}
,当我选择插入时,它会存储在内存中,但我希望将其发送到 URL 并且希望可以查看它在另一项活动中。
如何做到这一点请帮助我......
the following is the code which i am using to capture an image from the camera in my app
public void startCamera()
{
Log.d("ANDRO_CAMERA", "Starting camera on the phone...");
String fileName = "testphoto.jpg";
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, IMAGE_CAPTURE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_CAPTURE)
{
if (resultCode == RESULT_OK)
{
Log.d("ANDRO_CAMERA","Picture taken!!!");
imageView.setImageURI(imageUri);
}
}
}
after capturing the image and when i select insert it gets stored in memory but i want it to be sent to an URL and i want it to be viewed in another activity.
how to do this pls help me.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要图像的 URL。
您将在
SelectedImageURI
中获取 URI,然后您可以使用Intent.putExtra();
发送该 URI,这对我有用。
You need the URL of the image.
You will be getting the URI in
SelectedImageURI
, then you can send that usingIntent.putExtra();
This works for me.