![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVXMSQ8fOIY0NqJuFHFZlWutiSqx-aav_R3O7IXp4Yf4gFMcV-G_OkhmZorJiiuDkuAu5tFju4VzEYl5anlW_iENTKbS0E6nZE5xWNpRUYIwWKL3uJ_-mGEesMKNsUu0S9z3qbhc2op98/s320/shareimage+infopalacess.jpg)
ANDROID SHARING IMAGE USING SHARE INTENT
Today I am going to tell that how can we share images or files or other content without saving them to external memory. Because many users not do not grant permission for reading and writing of external storage due to some security concerns and this will save you from a lot of unnecessary code and permission in you application. Here we have to use a little hack which will save them into cache and then share it.
Let's Start!
We can share our content by following the simple three steps.
- Add the provider tag in your AndroidManifest.xml file.
- Defile the filepaths.xml file in xml directory.
- Save the image in the cache and then share it
Step 1: | First of All open Menifest file and add following code in your application tag in your Androidmanifest.xml file. |
Here com.infopalacess.shareImage is my application package name replace it with your own application name and append it with .fileprovider. For example com.youapplication.image.fileprovider.
You May Also Like
Step 2: | Now Create a new xml file in res folder and name as filepaths.xml and copy the following code and paste it there. |
Step 3: |
Now go to MainActivity.xml or whatever where you want to implement picture share method and add a Button and ImageView. Like Below; |
Step 4: |
Now go Finally go to MainActivity.java and Create a Picture share method by copying following code mentioned. |
That's it we have done it. Now we can share image from imageview without saving into External Storage.
0 Comments