I hope you understand my question :-)
Sorry for the delay, I found a solution, but not very good ...
First, I really searched for a while and looked at the Picasso code. It looks like you should provide your own bootloader and other stuff. But then why should I use lib ...
And then I suppose the Picasso project / architecture just caches the file in the internal storage. Perhaps because external storage is not always available (for example, a user can connect his SD card to his computer), or maybe because external storage is not as fast as internal ... This is my guess. In other words, other applications cannot access the internal storage of the current application, so this resource cannot be executed.
So I made a really normal decision. I just wait for Picasso to give Bitmap , and compress it to a file in an external file, and then make a share. This seems like a bad solution, but it really solves the problem, yes ...
You should know if the external cache directory is accessible or not. If not, you cannot do this promotion. And you need to put the compression task into the background thread, so waiting for an external file, cached ... It seems like a bad solution? I think so...
Below is my project code, you can try ...
private boolean mSaved; // a flag, whether the image is saved in external storage private MenuItem mShare; private Intent mIntent; private ShareActionProvider mShareActionProvider; private File mImage; // the external image file would be saved... private Target target = new Target() { @Override public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) { new Thread(new Runnable() { @Override public void run() { FileOutputStream os = null; try { String dir = CatnutUtils.mkdir(getActivity(), Constants.FANTASY_DIR); // check the exteral dir avaiable or not... String[] paths = Uri.parse(mUrl).getPath().split("/"); mImage = new File(dir + File.separator + paths[2] + Constants.JPG); // resoleve the file name } catch (Exception e) { // the external storage not available... Log.e(TAG, "create dir error!", e); return; } try { if (mImage.length() > 10) { // > 0 means the file exists // the file exists, done. mIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImage)); mSaved = true; return; } os = new FileOutputStream(mImage); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); mIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImage)); mSaved = true; } catch (FileNotFoundException e) { Log.e(TAG, "io error!", e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { Log.e(TAG, "io closing error!", e); } } } } }).start(); mFantasy.setImageBitmap(bitmap); } @Override public void onBitmapFailed(Drawable errorDrawable) { mFantasy.setImageDrawable(errorDrawable); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { if (placeHolderDrawable != null) { mFantasy.setImageDrawable(placeHolderDrawable); } } }; @Override public void onPrepareOptionsMenu(Menu menu) { mShare.setEnabled(mSaved); } public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fantasy, menu); mShare = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) mShare.getActionProvider(); mShare.setActionProvider(mShareActionProvider); mShareActionProvider.setShareIntent(mIntent); }
Finally, call Picasso.with(getActivity()).load(mUrl).into(target);
When the file is saved, the user can click on the shared menu with the shared resource.