Share Photos & Files Using FileProvider

  Рет қаралды 16,632

AndroidTutorials

AndroidTutorials

7 жыл бұрын

This tutorial will show you how to share data (texts, photos, files, etc.) with other apps that are capable of receiving it. We will be using FileProvider to share them.
Github: github.com/Kiarasht/Android-T...
Documentation: developer.android.com/referen...

Пікірлер: 56
@androidtutorials9328
@androidtutorials9328 5 жыл бұрын
After couple of requests, I have made another similar tutorial, but with audios (mp3) incase anyone is interested. kzfaq.info/get/bejne/itupfLqJ0MnGqpc.html
@zakblacki
@zakblacki 4 жыл бұрын
How to choose Image to shre from gallery
@androidtutorials9328
@androidtutorials9328 4 жыл бұрын
@@zakblacki I have put this on my todo list to post a video of. Thanks For now try something like this: stackoverflow.com/questions/38352148/get-image-from-the-gallery-and-show-in-imageview
@khchin2528
@khchin2528 6 жыл бұрын
Finally somebody is explaining this clearly. Thanks for that!
@artcodezen
@artcodezen 4 жыл бұрын
Thanks so much man, you saved my life. Your tutorial is very good, objective and simple.
@tehleelmir4407
@tehleelmir4407 2 жыл бұрын
Thanks man, wherever you are 🐥
@zeta0084
@zeta0084 5 жыл бұрын
Just want to say, thank you so much bro!
@rishabhnayak4243
@rishabhnayak4243 4 жыл бұрын
Badia Bataya bro maza aa gya.
@LucasMasciotra
@LucasMasciotra 7 жыл бұрын
realy u save my ass got a new suscriber , u are the only one that explains how fileprovider works on a easy way u cant imagine how greatfull i am after ours of app crashing bless u !
@LucasMasciotra
@LucasMasciotra 7 жыл бұрын
ty dude its the only updated tutorial about this
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
Welcome! Glad it was helpful.
@harshbarnwal1879
@harshbarnwal1879 5 жыл бұрын
thanks, worked like a charm
@engosm2009
@engosm2009 4 жыл бұрын
Thank you very much, for couple of days i am stuck in this matter.
@PankajGupta-gh9cm
@PankajGupta-gh9cm 4 жыл бұрын
Very helpful ..
@huseyintunc1695
@huseyintunc1695 6 жыл бұрын
How can we do it for audios (mp3) ? (Saving sd card codes)
@i-nozex
@i-nozex 3 жыл бұрын
I'm strugling quite a bit in the oposite end, on how to handle/request the shared data (my app will be the receiver of the shared content, in my case is a CSV file, I'm able to get a "content://" path but not the actual shared file)... It's been quite hard to find resources in this matter, anyone has a good tutorial/how does it work/code example or any other kind of information that could help me to understand and implement? thanks!
@DjangoMx
@DjangoMx 5 жыл бұрын
Hi there I'm using a file provider for take a picture from the camera an save it in the internal storage and everything works fine but when I make a little change to the code for save it the image in the private files of my app the image not is saved, I getting private files with getFilesDir(), one thing more that only happen in android KitKat because un higer version I can save the image in the last directory and everything works fine, do you have some idea about that wat happen?
@ramvilashkumar2255
@ramvilashkumar2255 5 жыл бұрын
How to implement it for those photo that are coming in the recyclerview from the net that are not stored in the drawable.Please make a video of it or code for it
@ebpvgeb
@ebpvgeb 6 жыл бұрын
While sending an audio. It just stuck on "still pending" status. What would I need to share an audio file that's already been save on External storage?
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
It shouldn't get stuck. It either fails to share it (permission wasn't given correctly) or it does (yay!). If you are using external storage, you would most likely need this path. developer.android.com/reference/android/support/v4/content/FileProvider#SpecifyFiles Environment.getExternalStorageDirectory().
@chandanaphere
@chandanaphere 6 жыл бұрын
The font is too small for me to watch this on mobile.thanks for doing this but can you adjust the font size
@kiarash32
@kiarash32 6 жыл бұрын
The code is available on Github.
@jaygitonga2026
@jaygitonga2026 3 жыл бұрын
hey , do you have this but for pdfs?
@CeorNormal
@CeorNormal 4 жыл бұрын
And if I want to open an excel file? Somebody could please tell me what can I do? I am almost two days trying that
@Ok-Chance
@Ok-Chance 4 жыл бұрын
hello i have photos in a table , how can i share it , ty
@abhijeetsingh9083
@abhijeetsingh9083 5 жыл бұрын
it's show "the file format is not supported" on sharing with whatsapp and show "unable to attach file" on gmail
@khchin2528
@khchin2528 6 жыл бұрын
Sir, how to take image from the camera and crop it FOR ANDROID 7.1.2? I am using FileProvider already but there is IllegalArgumentException error. Guessed something to do with uri. Thanks in advance!
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
Cropping is something I haven't done much with yet. Are you getting the IllegalArgumentException when cropping or using FileProvider?
@khchin2528
@khchin2528 6 жыл бұрын
The exception is when FileProvider is called. Error line: Uri uri = FileProvider.getUriForFile(MainActivity.this, "com.example.admin.newcrop.provider", createImageFile()); And this is the createImageFile() private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; //File storageDir = new File(Environment.getExternalStoragePublicDirectory( // Environment.DIRECTORY_DCIM), "Camera"); File image = File.createTempFile(imageFileName,".jpg"); // Save a file: path for use with ACTION_VIEW intents mCurrentPhotoPath = "file:" + image.getAbsolutePath(); return image; } I removed the storageDir due to another error when i put the directory into createTempFile.
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
That could be based on a lot of things unfortunately, IllegalArgumentException is a common exception. I would suggest posting the stack trace here or stackoverflow to see if someone is getting the same thing.
@khchin2528
@khchin2528 6 жыл бұрын
Alright sir. Thanks a lot!
@RealMeenakshiDangi
@RealMeenakshiDangi 5 жыл бұрын
And in this showing - file format not supported. I am trying to share the clicked image. Kindly help.
@himanshukandwal8710
@himanshukandwal8710 4 жыл бұрын
its because you were sharing a null file.
@seemstwo8919
@seemstwo8919 6 жыл бұрын
it's often more difficult to see these videos with the black backdrop
@juniorlanga4505
@juniorlanga4505 5 жыл бұрын
Thanks for the video, very helpful. But how do I share a picture from an ImageView ?
@androidtutorials9328
@androidtutorials9328 5 жыл бұрын
You will have to save the file into the phones disk before being able to share it to other apps. If the image is loaded from the internet, you can just share the url to that image.
@1234zaptor
@1234zaptor 6 жыл бұрын
Subscribed.. I just wanna ask is this the same as shareit function? if it does. well this is awesome!
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
shareit app? Sort of. But you would need like a bluetooth app to transfer offline.
@1234zaptor
@1234zaptor 6 жыл бұрын
how about connecting hotspot?. is that possible? hope you can give me ideas on how to..
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
All this does is share files with other apps. If an app has capabilities of sharing files through bluetooth & hotspots, then yes you should be able to share it with those.
@RomanReigns-tg5qm
@RomanReigns-tg5qm 5 жыл бұрын
why didn`t we use uri.parse()
@Imjaved
@Imjaved 6 жыл бұрын
Hello Sir You have Done such great job but here we have problem with this coding on some of android version: The problem is "java.lang.NullPointerException" on These Version Android 4.4 Android 5.1 Android 7.1 Android 6.0 Other Android Version Working Fine... Plz let me know if you have any idea about it.....thank you......
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
You wouldn't need these for anything below API level 23 since runtime permission was added in 6.0, for the other two let me know if you have a stack trace.
@RealMeenakshiDangi
@RealMeenakshiDangi 5 жыл бұрын
Thanks a lot... how to do it image from imageView?
@androidtutorials9328
@androidtutorials9328 5 жыл бұрын
You will have to save the file into the phones disk before being able to share it to other apps. If the image is loaded from the internet, you can just share the url to that image.
@etelot
@etelot 3 жыл бұрын
How about PDF files anybody?
@fabianomelquiades1629
@fabianomelquiades1629 6 жыл бұрын
how to do this with audio?
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
It should work the same way, instead you change the setType. For example for mp3: shareIntent.setType("audio/mp3"); or all audio files shareIntent.setType("audio/*");
@smhily
@smhily 4 жыл бұрын
@@androidtutorials9328 What about when saving the files to storage? You use bitmap to do that, but how would you do it for audio?
@androidtutorials9328
@androidtutorials9328 4 жыл бұрын
@@smhily This one is for audio. kzfaq.info/get/bejne/itupfLqJ0MnGqpc.html In this case I'm moving them to the download folder, but you can place them where-ever based on your needs.
@koshalgarg4791
@koshalgarg4791 6 жыл бұрын
Why do you choose such a theme
@androidtutorials9328
@androidtutorials9328 6 жыл бұрын
Bad eyes. Need something that's dark. Color also helps in differentiating stuff.
@CanalRenaultClio
@CanalRenaultClio 2 жыл бұрын
FileProvider is jut a ridiculous way to solve a problema that does not exist. Now just a simple file share that should take 5 lines of code requires to create 5 files
@micromymario23
@micromymario23 2 жыл бұрын
It sucks from all points of view, it doesn't make any sense, not to mention what they did in the file management on version 30 of the SDK. I believe that whoever is in charge of google doesn't have the slightest idea of ​​what it means in PRACTICE to make such changes for a programmer and for the management of all his applications that suddenly stop working.
@HARVINDERSINGH-eu1bo
@HARVINDERSINGH-eu1bo 5 жыл бұрын
font size is too large next time make it more smaller.....
@HARVINDERSINGH-eu1bo
@HARVINDERSINGH-eu1bo 5 жыл бұрын
font size is too large next time make it more smaller.....
Deep Linking Between Apps With Android
12:16
AndroidTutorials
Рет қаралды 6 М.
What's going on with Windows Laptops?
10:30
Marques Brownlee
Рет қаралды 2,6 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 8 МЛН
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 90 МЛН
Uris (Unique Resource Identifier) - Android Basics 2023
14:21
Philipp Lackner
Рет қаралды 22 М.
FileProvider Android: Sharing Audio Files
10:52
AndroidTutorials
Рет қаралды 3,2 М.
Create a FileProvider to store an image on Android
8:22
Brandan Jones
Рет қаралды 6 М.
Keyframe animations with ConstraintLayout and ConstraintSet
3:14
Android Developers
Рет қаралды 104 М.
Write/Save File to External Storage | Android Studio
7:56
Stevdza-San
Рет қаралды 46 М.
Swipe gestures in Recycler View | Android
18:47
Mafia Codes
Рет қаралды 62 М.
Receive Data From Other Apps With Android
12:47
AndroidTutorials
Рет қаралды 4,8 М.
Create a FileProvider and provider path XML in Android
7:49
Brandan Jones
Рет қаралды 27 М.
Android File Share and Receive from Other App
12:54
Super Coders
Рет қаралды 10 М.
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 8 МЛН