我已经开发了一小部分。它可以拍照只是现在不存储。我想从Android应用程序上传图片(使用相机)到服务器。我使用过改造库,网络服务(asp.net)。我怎么能这样做?
清单:
public class UploadPhotoActivity extends AppCompatActivity {
static final int REQUEST_IMAGE_CAPTURE = 1;
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload_photo);
imageView=(ImageView)findViewById(R.id.imageView);
}
public void SelectPhotoMethod(View view){
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(imageBitmap);
}
}
}
CODE:
#include <conio.h> // put this somewhere up at the top of the file
void intro()
{
cout << "Stuff being said " << endl;
cout << "More stuff being said " << endl;
cout << "Press 'enter' to continue or 'backspace' to skip...";
int result = _getch(); // returns number equivalent of a character
if (result == 8) // 8 is the number equivalent of backspace
return;
...
code
...
}
答案 0 :(得分:2)
MultipartEntity
将MultiPart
图片上传到服务器或Volley
或Retrofit
库,以最少的代码将图片上传到服务器。MultiPart
Uploading Camera Image, Video to Server with Progress Bar
Volley或Retrofit