This repository contains useful code taught in the Official Professor DK Lecture Series in Youtube! Learn Everything the easy way!
98
stars
487
forks
source link
i can't show image in my storage and ImageView i write same code like you but its haven't work #3
Open
jcredking opened 6 years ago
Button b1 = (Button)findViewById(R.id.imagebtn1); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,"select image"),RESULT_LOAD_IMAGE); } }); protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RESULT_LOAD_IMAGE && requestCode== RESULT_OK && data.getData() !=null){ selectimage = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),selectimage); imageE.setImageBitmap(bitmap); selectImage(); } catch (IOException e) { e.printStackTrace(); } }
public void selectImage(){ StorageReference imageReference = storageReference.child(firebaseAuth.getUid()).child("Image").child("Selected Imaage"); UploadTask uploadTask = imageReference.putFile(selectimage); uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(nav.this,"Image cant slecting",Toast.LENGTH_SHORT).show(); } }).addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(nav.this,"Image Selected Sucessfuly",Toast.LENGTH_SHORT).show();
}
});
}