java – How to share image in android studio for all APIs?

I need your help, I am uploading apps to the Huawei appgallery store, and the person who is reviewing my app tells me that my application stops when he presses the share button.
When I use my app there is no problem, but I think this can happen through the API.
How can I improve or correct this code?
I hope someone can help me. Thanks !

public class MainActivity extends AppCompatActivity {

    Button btn_shareimage;

    //Share Image
    private void shareimage(Integer image){
        Bitmap icon = BitmapFactory.decodeResource(getResources(), image);
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("image/jpeg");

        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, "title");
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
        Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                values);
        OutputStream outstream;
        try {
            outstream = getContentResolver().openOutputStream(uri);
            icon.compress(Bitmap.CompressFormat.JPEG, 100, outstream);
            outstream.close();
        } catch (Exception e) {
            System.err.println(e.toString());
        }
        share.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(share, "Share Image"));
    }
    //

    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.textview);
        button = findViewById(R.id.button);


        btn_shareimage = (Button) findViewById(R.id.btn_shareimage);
                btn_shareimage.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        //Share image
                        shareimage(R.drawable.image);

                    }
                });

    }
}