as the title says, Im getting errors when trying to share to Gdrive some pictures. However, in my device, the application is working without problems, but when I tested it to 2 other devices, they encountered an error saying Upload 'Error, Cannot plan the upload of the file'. Need help as I have no idea what is causing this. Much appreciated.
Here is my code for the share intent. Thank you.
private void shareImage() {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
drawable = (BitmapDrawable) saveImage.getDrawable();
bitmap = drawable.getBitmap();
File file = new File (getExternalCacheDir()+"/"+""+".png");
Intent shareIntent;
try {
FileOutputStream outputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG,100, outputStream);
outputStream.flush();
outputStream.close();
shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.setPackage("com.google.android.apps.docs");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}catch (Exception e)
{
Intent i = new Intent(Intent.ACTION_VIEW);
throw new RuntimeException(e);
}
startActivity(Intent.createChooser(shareIntent,"Upload to Gdrive"));
}