Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

android - Is there a way to get around size limit for "Upload to Photos"

I'm using this code to share a collection of images:

final ArrayList<Uri> imageUris = new ArrayList<>();
for (final ImageBean selectedImage : ImageBean.getSelectedImageBeans(imagesBeans)) {
    final File imageFile = new File(selectedImage.getPathToImage().getPath());
    final Uri contentProviderUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", imageFile);
    imageUris.add(contentProviderUri);
}
final Intent shareIntent = new Intent();
shareIntent.setType("image/*");
if (imageUris.size() == 1) {
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUris.get(0));
} else {
    shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
    shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
}
context.startActivity(Intent.createChooser(shareIntent, context.getResources().getText(R.string.share_images_intent)));

I'm mainly interested in uploading to Google Photos. This works great for an image of 600KB, but fails for a 5 MB image (24MP from my camera). So apparently there's a size limit, but as the error happens in the Google Photos activity, I'm unable to debug it (or I don't know Android Studio well enough on how to do that).

Is there a way I can change my Intent so I can upload multiple 24MP images, or is the size limit a given and I need to work around it (eg. by implementing the Google Photos API)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It turns out that Google Photos doesn't play well with the FileProvider. The upload works when using the public content URI, to be found using something like

int mediaId = cursor.getInt(getColumnIndexForMediaID());
Uri publicUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(mediaId));

Now I'm back at Can't edit image in Google Photos after "Upload to Photos" activity


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...