0

what i am trying to do

I have captured a screenshot of an activity and have stored it in my sdcard/BackgroundRemover folder and trying to share(share Intent) it to other app using file provider using the path where it was saved !!

here is error

java.lang.IllegalArgumentException: Failed to find configured root that contains /file:/storage/emulated/0/BackgroundRemover/1639931544873.jpg at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:800) at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:442)

here is my image / where image is stored

link= file:///storage/emulated/0/BackgroundRemover/1639931544873.jpg

file provider i have used lot of like ......

Java Code adn file provider i have used /geting image uri using file provider and ....

<root-path name="root" path="BackgroundRemover" />

and also tried this one 

<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path
        name="external"
        path="BackgroundRemover/" />
    <external-files-path
        name="external_files"
        path="BackgroundRemover/" />
    <cache-path
        name="cache"
        path="BackgroundRemover/" />
    <external-cache-path
        name="external_cache"
        path="BackgroundRemover/" />
    <files-path
        name="files"
        path="BackgroundRemover/" />
    
</paths>

java code here !!

Uri imageUri = FileProvider.getUriForFile(getApplicationContext(),
                        "com.battlingbugs.backgroundremover.provider", new File(link));
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(intent.EXTRA_STREAM, imageUri);
                intent.setType("image/jpg");
                startActivity(Intent.createChooser(intent, "share by"));

Bin jafar
  • 1
  • 2
  • Please just post your code starting with the link as we have no idea what is in it and its crucial here. – blackapps Dec 19 '21 at 18:08
  • i did not get that, i have shared all the things like java code and xml file_ provider and the error that i am facing – Bin jafar Dec 19 '21 at 18:20
  • No. You started your code with `, new File(link))`. And you should start your code with `link` instead. Start with the beginning – blackapps Dec 19 '21 at 18:59
  • thanks that was the problem that you mentioned !! Thanks link should be as link = /storage/emulated/0/BackgroundRemover/1639931544873.jpg; – Bin jafar Dec 23 '21 at 18:35

0 Answers0