Image upload to cloudinary in Android Java

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video we are going to see how we can upload image into the cloud nori in android so i am going to open the google here i am going to search cloud nori so our result is loaded just go to the bottom and see cloudnary.com right i just going to click this one so our site loaded successfully this official site for the globally i just going to click the sign up for free in order to use the cloud nuri i should have to create an account so i just click and create an account you guys see like there are one question right the primary interest i'm going to click the first one and i i'm going to create an account so it send a mail verification i just go to my mail and click the closenery and i just click sign in to validate your email address so there are some free setup here so i just going to click the developer i just click continue so this is my account right so i just going to click the dashboard here in this dashboard they are providing all account details the cloudtenary name api key apa secret and apa environmental variables right this is the necessity to upload a image to the cloud nuri as of now our cloud nuri account setup is done so just go to that android studio and create a new android studio project so create a new project here i'm going to choose the empty activity so i'm going to create so here i'm going to choose the language as java and minimum api 5.0 just click finish so here our android project loaded successfully so i just going to expand the resources and layouts and go into the main.xml so here i want to create one image view i'm just going to click this text delete this text so here i want to choose a image you i just drag and drop to here so for the sample i just clicked on avatar so i just click ok so right click sender horizontal right click center vertical so i'm going to expand like this and now you do so i'm going to finally i'm going to click one button here so i'm going to arrange the button so i'm going to the split view so here i want to change the button property here the text has upload image so now i am going to the main activity so i am going to declare the button and image view here i am going to give the ids for the views so here we want to observe something what will be going to achieve in future right so in first thing user want to click there image view so first you are going to click the image you so after we click the image you will go into the gallery so then we select one image from the gallery then after we selected that image will appear here then user want to click the upload image so after user click up upload image that will go into the cloud nori so that's all so just go to the and describe our point here user want to click the image view second one select image file here you can choose whatever you want image pdf video file from select the file from the gallery the great one show the image in the image view so the preview of the image in so the preview of the image in image view and the fourth one click the upload button to upload image to the cloud node so that's all guys so these are the steps we are going to follow in the future so first i'm going to read this one user want to click the image view right image view dot set one click listener new one click listener that's all and another thing is like we can use as a lambda function here so i just click this is not necessary i just change right so as a lambda function so this is java 8 you know the advantage of java 8. so here i am going to list the things which are going to achieve in the future so in order to access the internal storage we have to ask the permission from the user so i'm going to achieve this one ask the user to give the media permission so this is the first thing and secondly second moving to the gallery so first i'm going to achieve the first one ask user to give the media permission so i just go to the manifest here i'm going to achieve user's permission read so this is for the storage this is for the storage storage so use the internet access so this is not necessary to ask a user i just have to declare in the manifest internet permission right that's all so just go to the main activity so here one dot one so this is the one this is one right so i mean 1.1 so here i mentioned 1.1 1.2 so here i'm going to achieve the 1.1 that's why i created one method i just click so this is the help of the android studio i just create create a method here so inside the method i'm going to ask the permission from the user right contacts comebacks dot check cell permission so here i want to pass the context so this contact is the activity name is main activity dot this then manifest dot permission read read external storage story i guess gender so i have to equal package manager dot permission granted so i just minimize this one so i hope you guys now you can see clearly so what i did here i asked the user the cell phone is in so if the permission is granted then i have to select the image so this is a function not get implemented or else so i'm going to explain the request permission method check self the permission so here if the user already granted that redirectional storage permission so i'm going to access this select image so it's not yet created or else i am requesting the read external storage permission this is not related to the image upload this is related to the permissions right so that's all for the permission so i'm going to implement this select image so i just click here i'm going to create one method so inside the method i'm going to select the image select the image from gallery so how we can select the image which is inside the gallery right so we can we have to use the intent right intent so i'm going to import the intent in both class i'm creating one object in in so make sure you uh you can't create the indian object as a hint because in this uh variable type right so just checking i'm creating the intent in or just create indent right small symbol intent right so new intent so i'm calling the intent and here i have to specify the type so in the set type method i have to mention image so this will show all the images in the gallery so i finish this one so make sure to use the correct syntax so if you want if you want you can use pdf if video so in my case i'm going to select the images okay inside the gallery okay then i'm calling the intent indian object and set action in the action i have to choose intent dot action get content a content inside that gallery right so i have to mention like this start activity for result so first i have to mention the indian object intent and second parameters as a you know we have to mention one integer for the image request that's for the request code i just mentioned one here so the good way is here request good and the request code i just mentioned the integer right this is not a good practice so i'm going to the top and i'm going to create private static hint image request one so so so afterward so i created one integer so i copy this integer so i paste it here and here as well and the only thing i have to mention uh this is deprecated right so if the line says we can't use it we can't use this is work but in future they will going to remove right so i just click and go inside the short activity for results and i can see why it's deprecated and i think better to see this result in the last so as of now i keep it as it is in future i mean in the end of the video i will going to check this out activity result and i will fix this one so as of now this is fine this will work correctly so i have to override one method which is called onactivityresult so i am going to overwrite the method inside down active users i am going to check the condition here request code right so request code result code and data so i am going to choose the request code first request code must be one write this code right image request and second one is a result code activity dot result okay data which is from the internet which is means not equal to null mean indian have some data right if the indian have some data and and this is the final connection here data dot get data not equal to null right which means this have some value so then i'm going to get the url data right so i'm going to get the image path so data get data you can see data is a url right so so what i'm going to do is i'm going to declare one so going to declare the uri uri uri so i'm going to select that image path right i'm going to name the uri as image path and i'm storing to the image path that's all so after i stored the image path into this image path i'm going to show it into the ui right so i come here so i'm going to tell the follower again after user click the image you so we are navigating the gallery in the gallery we have choose one image after we choose the image that will direct to a web after we direct to our app our intent have some data which is having this previous selected image path that's called in the url right so we have to show the preview here right so in order to show the preview i'm going to use one open source library called picasso i'm going to search and write picasso android image view so this is open source library so this is official website and i'm going to open another link as well github so so we have to open this link as well so this is obvious documentation for the picasso so in order to use the picasso we have to read the recommendation carefully but this is a simple way so i just go into the top bottom so i'm going to the bottom i cl i copy this the gradle and come back the app and expand the gradle script and go to the build.gradle in the bottom picasso library right so i paste it here but i have to mention the version so here i have to mention the version right so i i come i go to that github and in the bottom they mention the latest version right or else i just copy this one and and paste it here i just click sync now our library added successfully now i am going to that documentation so i am going to copy this documentation sample code and come back to our main activity so here after user select the image from the gallery i have to show that image into the image view right so i paste it here i just click i import the library all tender or if you are using a mac user just click option enter then here i have to paste the path right so in our case the path is image path that's ura right so that part you are right then image view right so i already named the image you assimilate you so no need to change here that's all uh just check this functionality now oh actually that our image you're not showing up so what i'm going to do is i'm going to that main activity again so i'm going to sleep view so inside that like i remove this tool structure compact and i just click structure in the structure i'm going to add [Music] android icon right android something like that got q design material ic launcher right this is a fine right so i again click the apply changes and restart okay now it's done right so i just click the image view so it's asking hello cloud nori android update of app name to access photo and media on your device i just click hello again click that image so it's directly direct to that gallery right so i just go here i click the images downloads so i have the image here so i just clicked my stack of flow image so after that i am going to click the update but as of now we not yet implemented this function right i'm going to back here as of now we completed these three steps right so user click the image you and navigate to that gallery then select the image and display to the image you so now the time to upload our image to the cloud nori right so just go to the google and search android cloudnari sdk so this will direct to that android sdk cloud nori so make sure cloudnauri.com android underscore integration i just click this one so this is the sdk documentation so just come to that installation so android sdk installation right here i have to copy this library i copy this one and go to our dependency we load gradle and add the comment here cloud nori sdk and i click sync now so what went wrong here oh my god you know in the documentation this is not a proper recommendation because you know in the you can see right they mention they are using a different syntax this is not this one right this is a different syntax right i don't know the name but you know this is a worst documentation i have seen right so as a developer we don't have any time to check this kind of stupid thing right so i just click try again so build successful right so i just minimize this one and i close the build.gradle come back to the documentation so i'm going to copy this metadata so i just click this copy clipboard and go to the manifest so after the activity tag i have to add this one so here i want to paste the cloudname url with our cloudname url so this is one cloudnary this one right i just copy this one and select and paste it and make sure guys you remove the cloudnery url in the bottom right so i only add cloudnary colon and my link right so that's all and i am going to that main activity now and this is the documentation again so here i have to config with init so i just copy this one the map object so inside oncreate method i'm going to call one method here that's called init config or whatever it is i just i so i'm going to change so you need config here i'm going to click here and create the method here inside the method i paste the things so option enter and option enter import class and option and and make sure guys i am using the mac so that's why i click option enter so if you are using uh your i mean if you are using windows you have to select all tender so that will automatically import the libraries so here there are three parameters but they only mention two things right so if you go to the cloud nori cloud nouri name api key api c grant right uh the apa environment variable we already set up in the manifest but in the cloudinary name apigee and api secret we not jet stick right so cloud nuri name so i'm going to the cloudinary name right so this is a key this is a cloudinary name right so i just copy this one and paste it here and second one is api key i just copy this one so i just enter config dot put second thing api underscore key say api key right api key and i paste apk here and config dot put the third parameter api secret underscore with c c r e a t api secret ap cigarette right so i copy this one so we just can choose this one right that's all guys as of now i'm going to comment this config dot secure so make sure what are the parameters we added in the map right so we add our cloud rename api key api cred so i set up all the cloud9 successfully so i'm going to that on create method so i'm going to implement the button click button set one click click new one click listener again i'm going to make this replace this one with lambda that's all so i'm going to call the media manager so this is media manager from the cloud nuri you have to make sure that is from the cloud nuri media manager dot get then upload right so in the upload we have to pass the url so in our case our image path that's called ura that's image path right i copy this one and paste it here so afterwards i'm going to observe right so in order to observe i going to call the callback function here so call back new upload callback right first one the interface right so this is from the cloud nuri so that's okay so i'm going to call the lock here first of all i'm going to create one lock message here main just got upload image image activity and i added two hashtags three hashtag here so inside i'm going to call this look here lock and start so that's a long tag i just remove this upload image is fine and our tag message now we can see that is the underlying return lines goes away that's all guys just restart the app reinstall and restart the app i forgot to do one thing i just go to that you know the method the button click method after i call the callback function i click here you can see here in the end of the callback i just call dispatch so that's all so another thing i'm going to do that's not necessary but you want to do that so in the init configuration i control cut i mean cut this one and paste over here so now you can see well organized code format right so now i'm going to click the run button again just click the button and click the image and click upload image and go to open the logins so in the login we can see the log messages which we put inside that uh you know button click here so success right we getting the success message so just go to the cloud neri and click the media manager media library and click the media library and you can see our uploaded image come here right i'm telling the additional information so just go to the settings [Music] in my settings just go to the upload and you can see here these are the upload presets so here you lose at the configuration so this is my configuration here so i just click edit and you can see here this is a default preset name and my signing mode is signed and i on actually these are the default you know it is defaultly on for every created account and this is a thing and other than that other configuration as well just go to the security and here you can restrict the types so these are things guys so if you wish you can study further now time to fix the deprecated sort activity for result i provide the link in the video description you can go and get there they don't stack off your question so if you guys don't know how to use the stack overflow just i i created one video just go there and watch the video [Music] so here one person provide the deprecated solution so what i'm going to do is i just want to copy this one so i'm using java make sure you select the java so i just copy this one and this is deprecated so what i'm going to do is i'm just comment this one and comment this this one as well and i paste here so there are one libraries i know jet implemented i just click all gender and select this one make sure activity dot result android x and all tender so here we have to do the operations so i just comment i just delete this one on it so this data right so what i'm going to do is so this is the intent data so you can see here right this indian data so i go i'm going to get the indian data into our image path right so i'm calling the image path equal data dot get data right so that's all and i copy this picasso and paste it here so image path and image view that's all guys so now i'm going to the code again and you can see here this is a method we have to use the code i copy this one and paste it over here so in 10 objects right so this is the indian object let me paste it here this object for the active reset launcher but that's fine guys so no need to keep the code i remove this one and now i turn the app again so i just click here so i again select so you can see here right this is working fine right so just click image upload and go to my cloud nuri and restart see this is working well right and finally one thing guys if you think this is a good explanation video just go to my youtube channel and hit the subscribe button this is a huge help for me so thank you so much
Info
Channel: Programming Make Sense
Views: 369
Rating: undefined out of 5
Keywords: android, cloudinary, imageupload, java, image upload, pdf, image, video, image picker, programming make sense, programming, programmer's life, coding, tutorial, android tutorial
Id: Q0WNouTBmcA
Channel Id: undefined
Length: 35min 17sec (2117 seconds)
Published: Sun Sep 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.