我正在使用此代码来分享分数的屏幕截图:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/png");
Uri image = Uri.parse(Environment.getExternalStorageDirectory().toString() + "/sharescore.png");
try {
// create bitmap screen capture
View v1 = v.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(image.getPath());
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
sharingIntent.putExtra(Intent.EXTRA_STREAM, image);
startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_via)));
当我使用“imgae/jpeg”类型时,它适用于 Whatsapp Twitter 等,但不适用于 snapchat 和 Instagram。它导致错误“所选图像无法打开”。我怎样才能使这项工作适用于 snapchat 和 instagram。