S
S
Stanislav Prokopiev2018-09-20 15:18:32
Java
Stanislav Prokopiev, 2018-09-20 15:18:32

"Creating image file to upload" in Android Studio project?

Since Monday I have been trying to implement image loading, which has already petrified the spine (((.

private final static int FILE_CHOOSER_RESULT_CODE = 10000;



private void openImageChooserActivity() {
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILE_CHOOSER_RESULT_CODE);
  }

  private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_PICTURES);
    File imageFile = File.createTempFile(
        imageFileName,  /* prefix */
        ".jpg",         /* suffix */
        storageDir      /* directory */
    );
    return imageFile;
  }

I'm new, I don't know much yet. There is no one to tell ... Maybe someone knows the solution to this problem? Respond!!!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question