I want to share an image file including a url to the other applications and my code is working fine with android 9 and below but it's not working with android version 10. I'm not able to figure out the problem yet. Here is the code and please let me know if i'm missing something.
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
path = args[0];
String idStr = path.substring(path.lastIndexOf('/') + 1);
File filepath = Environment.getExternalStorageDirectory();
File dir = new File (filepath.getAbsolutePath() + "/Top Images/");
dir.mkdirs();
String fileName = idStr;
file = new File(dir, fileName);
Ion.with(getApplicationContext()).load(path)
.write(file);
return null;
}
@Override
protected void onPostExecute(String args) {
// TODO Auto-generated method stub
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/gif");
share.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(SlideImageActivity.this, BuildConfig.APPLICATION_ID + ".provider",file));
// SHARE URL
share.putExtra(android.content.Intent.EXTRA_TEXT,getString(R.string.play_share_app));
startActivity(Intent.createChooser(share, "Share the photo"));
pDialog.dismiss();
}