【问题标题】:how to upload the image taken by calling camera activity from android phone?如何上传通过从Android手机调用相机活动拍摄的图像?
【发布时间】:2010-07-01 09:55:05
【问题描述】:

嗨,我有一张通过调用 image _capture 从 andorid 获取的图像 如何将其上传到 Windows 服务器?

        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
             startActivityForResult(intent, 0);


      public void onActivityResult(int requestCode, int resultCode, Intent data) {

 super.onActivityResult(requestCode, resultCode, data);


 if (resultCode == RESULT_CANCELED) {
 Toast toast = Toast.makeText(this,"camera cancelled", 10000);
 toast.show();
 return;
 }

// lets check if we are really dealing with a picture

 if (requestCode == 0 && resultCode == RESULT_OK)
 {

     Bundle extras = data.getExtras();
        Bitmap b = (Bitmap) extras.get("data");
        //setContentView(R.layout.main);

        ImageView mImg;
        mImg = (ImageView) findViewById(R.id.head);
        mImg.setImageBitmap(b);
   // save image to gallery
     String timestamp = Long.toString(System.currentTimeMillis());
     MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp);

 }

【问题讨论】:

  • 问题是什么?你要上传到哪里?
  • 嗨,我有一张通过调用 image _capture 从 andorid 获取的图像,我如何将其上传到 Windows 服务器?

标签: android


【解决方案1】:

这正是您需要做的How to send HTTP POST request and receive response?

你也可以看看这篇文章http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload。 POST 上传示例应该会有所帮助。

【讨论】:

    【解决方案2】:

    我建议您从图库活动中调用图像捕获活动。原因是您将拥有将存储在默认位置的全尺寸图像,因此当您完成图库活动时,您将拥有该全尺寸图像的路径。 Intent 并非旨在将大文件传递给另一个活动。我还看到相机拍摄的图像(由 android.media.action.IMAGE_CAPTURE 拍摄)尺寸很小。所以请参考我的blog,它可以帮助您完成图像捕获和上传任务。

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 2010-10-20
      • 2017-03-07
      • 2011-07-31
      • 2012-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多