0

On Oreo version of Android the app crashes when I share the image, but it works on Android versions below Oreo.

Here is the code:

File f = new File(Environment.getExternalStorageDirectory() + File.separator + "bala.jpg");
    try {
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
        fo.close();
    } catch (Exception e) {
    }
Uri uri = Uri.fromFile(f);
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("image/*");
    String shareBody = "In Tweecher, My highest score with screen shot";
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
    sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);

    startActivity(Intent.createChooser(sharingIntent, "Share via"
Markus Kauppinen
  • 2,851
  • 4
  • 17
  • 28
  • You could have a look at the crash log as it will provide relevant details. There's some guidance in [Unfortunately MyApp has stopped. How can I solve this?](https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this). – Markus Kauppinen Aug 27 '20 at 08:13
  • **do you check the Permissions??** at first you should check the Permissions you could help from this library Dexter --> [dexter library](https://github.com/Karumi/Dexter) – mohammad kazemienjad Aug 27 '20 at 19:57
  • yes, i provide the permission – Sakthi Balan Aug 28 '20 at 08:26

0 Answers0