"how to get path of captured image in android" Code Answer's

You're definitely familiar with the best coding language Java that developers use to develop their projects and they get all their queries like "how to get path of captured image in android" answered properly. Developers are finding an appropriate answer about how to get path of captured image in android related to the Java coding language. By visiting this online portal developers get answers concerning Java codes question like how to get path of captured image in android. Enter your desired code related query in the search bar and get every piece of information about Java code related question on how to get path of captured image in android. 

how to get path of captured image in android

By alibn99alibn99 on Jan 06, 2021
protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
        Bitmap photo = (Bitmap) data.getExtras().get("data"); 
        imageView.setImageBitmap(photo);
        knop.setVisibility(Button.VISIBLE);


        // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
        Uri tempUri = getImageUri(getApplicationContext(), photo);

        // CALL THIS METHOD TO GET THE ACTUAL PATH
        File finalFile = new File(getRealPathFromURI(tempUri));

        System.out.println(mImageCaptureUri);
    }  
}

public Uri getImageUri(Context inContext, Bitmap inImage) {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
    return Uri.parse(path);
}

public String getRealPathFromURI(Uri uri) {
    String path = "";
    if (getContentResolver() != null) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
            int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
            path = cursor.getString(idx);
            cursor.close();
        }
    }
    return path;
}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the Java based application and are stuck on how to get path of captured image in android can get a collection of related answers to their query. Programmers need to enter their query on how to get path of captured image in android related to Java code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to get path of captured image in android for the programmers working on Java code while coding their module. Coders are also allowed to rectify already present answers of how to get path of captured image in android while working on the Java language code. Developers can add up suggestions if they deem fit any other answer relating to "how to get path of captured image in android". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to get path of captured image in android resolved professionally and stay updated to the latest Java updates. 

Java answers related to "how to get path of captured image in android"

View All Java queries

Java queries related to "how to get path of captured image in android"

how to get path of captured image in android get file name from file path in java android studio picasso circle image android get id of view get drawable from string android java string to path how to destroy activity in android add a button to toolbar android how to add chips dynamically android Android multiimage view android java string animations android java string video adapters in android Android dependency 'androidx.core:core' has different version for the compile (1.0.2) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution how to change color of radio button in android ecommerce app github android manifest merger failed in android studio android include layout set text in edittext android clear back stack android cant change button color when app run android studio android.permission.INTERNET thread android studio how to prevent screen rotating in app android studio internet access android manifest upload photo to server and view in api android change color of action bar android studio flutter doctor --android-licenses Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema date format in android read storage permission android Passing Data between fragments in Android using Interface android timer how to calculate distance between two points using latitude and longitude in android string to int in android linux get signing certificate SHA-1 how to get array input in java java get command line output java get class by string name how to get input of local date type java java string get ith char get LocalDate in specified format

Browse Other Code Languages

CodeProZone