Wednesday , June 29 2022

Firebase Storage Tutorial for Android – Android Coding by DMTechnolab

The package The trap.Simplified coding.Firebasstorage;

Import Android.Content.Intent;

Import Android.The graphics.Bitmap;

Import Android.The hate;

Import Android.the provider.Mediastore;

Import Android.Support.v7.App.AppCompatActivity;

Import Android.The.Bundle;

Import Android.Opinion.Opinion;

Import Android.Widget.switch;

Import Android.Widget.ImageView;

Import Java.I am.IOException;

public class Main activity Is spread AppCompatActivity come into force Opinion.OnClickListener / * Implementation click listener * / {{

// a constant to track the file selector intent

Private Fixed The last int PICK_IMAGE_REQUEST = 234;


Private switch Click the button;

Private switch Button load;

// image view

Private ImageView imageView;

// a URI object to store the file path

Private to hate file path;


Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);


// get ideas from layout

Click the button = ()switch) findViewById()R.Id.Click the button);

Button load = ()switch) findViewById()R.Id.Button load);

imageView = ()ImageView) findViewById()R.Id.imageView);

// Engage audience

Click the button.setOnClickListener()this);

Button load.setOnClickListener()this);


// method to show file choice

Private Zero showFileChooser()) {{

Intent is intended = New Intent());

is intended.Settype()“Image / *”);

is intended.Setation()Intent.ACTION_GET_CONTENT);

startActivityForResult()Intent.Crocker()is intended, “Select picture”), PICK_IMAGE_REQUEST);


// handling image selector activity result


Protected Zero onActivityResult()int request code, int results, Intent The data) {{

Super.onActivityResult()request code, results, The data);

If ()request code == PICK_IMAGE_REQUEST && results == RESULT_OK && The data ! = Invalid && The data.get data()) ! = Invalid) {{

file path = The data.get data());

try {{

Bitmap Bitmap = Mediastore.Images.Media.getBitmap()getContentResolver()), file path);


} Hold ()IOException I) {{






public Zero on click()Opinion Opinion) {{

// If the button clicked is to be selected

If ()Opinion == Click the button) {{



// if clicked button is uploaded

other If ()Opinion == Button load) {{




Source link

About dmtechnolab

Check Also

Simplified Coding

Android Hilt Tutorial – Injecting Dependencies with Hilt – Android Coding by DMTechnolab

You are welcome Android Hilt tutorial. I hope you all are aware of it Dependency …

Leave a Reply

Your email address will not be published. Required fields are marked *