I have a method that creates a screenshot of the device and then I share that screenshot. The problem that arises is that it works for all devices except for Huawei
This code is the one who executes the capture
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
This is the code that shares the action of
imageFile.setReadable(true, false);
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFile));
intent.setType("image/png");
startActivity(Intent.createChooser(intent, "Compartir imagen"));
I do not know why it does not let me send the screenshot and take the screenshot. I do not see the sharing modality