Комментарии:
Thanks you somuch ❤️
ОтветитьBhai thanks yar! Hafte se error par atka hua tha! Tune theek karva dia yar! Thnx bro! Jai Shree Ram
ОтветитьBest tutorial ❤️❤️❤️.... Can we check the quality of an image? I mean i want to store only high quality image otherwise show your image quality is bad please take another photo
ОтветитьCan u pls provide the source code..
ОтветитьMy phone does not have sd card, can i do the same when save to cache? Thanks
ОтветитьThanks a lot
Keep it up bro👍
After taking picture, onActivityResult is not calling, so the image is not displaying in image view in phone. But this works well when connected to emulator..
ОтветитьThe Image Not saved on Gallery How i can saved it
ОтветитьImage is not seen in imageview after taking pic. Working on emulator but not on phone Moreover your manifest has no permissions? Help me with it how to get image on screen . Everything is same as in ur code
ОтветитьDid a great job! Thank you.
ОтветитьBhai teri height kitni h
ОтветитьWhite hat Jr. Ads😂
Ответитьhow could you do that without giving camera permission
Ответитьvery helpfull.
Ответитьthanx very useful content
ОтветитьGreat tutorial man, thanks!
ОтветитьAwesome tutorial,thanks alot
Ответитьwhat program you use to do all this and how to install to phone
ОтветитьWhere the hell is declaration of "fileprovider" class?
How Android will know that "fileprovider" exists in the project?
Thanks. I've got another idea by this video
ОтветитьI have a problem, at the " intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); " it says: " Cannot resolve method 'putExtra(java.lang.String, Uri)' " why is that?
ОтветитьThank you so much Sir!
ОтветитьSir, why in the android studio emulator can open the camera but when I use my phone to open the app suddenly close...
Ответитьhow to save image my friend? I want close app and image is saved on phone
Ответитьexelent
ОтветитьThanks sir !
Ответитьthanks bro, helpful tutorial
Ответитьcould you show the full code on the net?plz
Ответитьthnxxx bro
Ответитьhow to save image after that
ОтветитьI don't know how to thank you, You've saved my job. God bless you.. never stop
making video and help people like me
Great explanation.
ОтветитьI love you man! Saved my ass
Ответитьhi, am quite new into this field of android application programming... so i am wondering if the image captured with the mobile camera is now stored into the computer specified file location? and can i access those images with openCV applications?
Ответитьpackage com.whitegoldapps.imageposter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
Button btnChoose;
ImageView imgView;
String currentPhotoPath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnChoose=findViewById(R.id.btnChoose);
imgView=findViewById(R.id.imgView);
btnChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String filename="photo";
File storageDir=getExternalFilesDir(Environment.DIRECTORY_PICTURES);
try {
File ImageFile=File.createTempFile(filename,".jpg",storageDir);
currentPhotoPath=ImageFile.getAbsolutePath();
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imgUri= FileProvider.getUriForFile(MainActivity.this,"com.whitegoldapps.imageposter.fileprovider",ImageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT,imgUri);
startActivityForResult(intent,1);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&&resultCode==RESULT_OK){
Bitmap bitmap= BitmapFactory.decodeFile(currentPhotoPath);
imgView.setImageBitmap(bitmap);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bao); // bmp is bitmap from user image file
byte[] byteArray = bao.toByteArray();
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("document55Images").child(UUID.randomUUID().toString());
//StorageReference filePath = FirebaseStorage.getInstance().getReference().child("profile_images").child(userID);
storageReference.putBytes(byteArray).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
final Uri downloadUrl = uri;
Toast.makeText(MainActivity.this, "uploaded "+uri, Toast.LENGTH_SHORT).show();
}
});
// Uri downloadUrl = taskSnapshot.getDownloadUrl();
// Toast.makeText(MainActivity.this, "uploaded", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"failed",Toast.LENGTH_LONG).show();
}
});
}
}
}
This The code I have integrated it with firebase firestore database
This is The code
package com.whitegoldapps.imageposter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
Button btnChoose;
ImageView imgView;
String currentPhotoPath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnChoose=findViewById(R.id.btnChoose);
imgView=findViewById(R.id.imgView);
btnChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String filename="photo";
File storageDir=getExternalFilesDir(Environment.DIRECTORY_PICTURES);
try {
File ImageFile=File.createTempFile(filename,".jpg",storageDir);
currentPhotoPath=ImageFile.getAbsolutePath();
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imgUri= FileProvider.getUriForFile(MainActivity.this,"com.whitegoldapps.imageposter.fileprovider",ImageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT,imgUri);
startActivityForResult(intent,1);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&&resultCode==RESULT_OK){
Bitmap bitmap= BitmapFactory.decodeFile(currentPhotoPath);
imgView.setImageBitmap(bitmap);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bao); // bmp is bitmap from user image file
byte[] byteArray = bao.toByteArray();
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("document55Images").child(UUID.randomUUID().toString());
//StorageReference filePath = FirebaseStorage.getInstance().getReference().child("profile_images").child(userID);
storageReference.putBytes(byteArray).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
final Uri downloadUrl = uri;
Toast.makeText(MainActivity.this, "uploaded "+uri, Toast.LENGTH_SHORT).show();
}
});
// Uri downloadUrl = taskSnapshot.getDownloadUrl();
// Toast.makeText(MainActivity.this, "uploaded", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"failed",Toast.LENGTH_LONG).show();
}
});
}
}
}
Hello sir,
I have an doubt!
Question:-how can i check captured image quality ?
Please, make a video on " How to make share images from imageview" app in Android Studio 🙏🙏🙏
ОтветитьThank You, comrade!
ОтветитьThank you very, very much
ОтветитьThank you! Very helpful!
ОтветитьBro You didn't Give Permissions In Manifest
ОтветитьThis saved me today ❤❤
ОтветитьAbsolutely terrific tutorial man. Thanks!!
ОтветитьThe code is awesome, thank you! But have a question:
Anyone of you guys met a problem like me below;?
When I create a picture it always has a 90° rotation.
Anyone know why?
Thank you so much this method helps me
ОтветитьGood tutorial
ОтветитьYou saved my life
Ответить