i spand kilka godzin, aby znaleźć to rozwiązanie ...Podziel obraz z ShareActionProvider od Picassa
więc postanowiłem podzielić się tym informatiom, może kogoś itwill pomocne :)
The pierwszy sposób, pokazany poniżej, pobiera mapę bitową z widoku i ładuje ją do pliku.
// Get access to ImageView
ImageView ivImage = (ImageView) findViewById(R.id.ivResult);
// Fire async request to load image
Picasso.with(context).load(imageUrl).into(ivImage);
a potem zakładając po zakończeniu ładowania obrazu, to w jaki sposób można wywołać akcję:
// Can be triggered by a view event such as a button press
public void onShareItem(View v) {
// Get access to bitmap image from view
ImageView ivImage = (ImageView) findViewById(R.id.ivResult);
// Get access to the URI for the bitmap
Uri bmpUri = getLocalBitmapUri(ivImage);
if (bmpUri != null) {
// Construct a ShareIntent with link to image
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setType("image/*");
// Launch sharing dialog for image
startActivity(Intent.createChooser(shareIntent, "Share Image"));
} else {
// ...sharing failed, handle error
}
}
// Returns the URI path to the Bitmap displayed in specified ImageView
public Uri getLocalBitmapUri(ImageView imageView) {
// Extract Bitmap from ImageView drawable
Drawable drawable = imageView.getDrawable();
Bitmap bmp = null;
if (drawable instanceof BitmapDrawable){
bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
} else {
return null;
}
// Store image to default external storage directory
Uri bmpUri = null;
try {
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis() + ".png");
file.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
bmpUri = Uri.fromFile(file);
} catch (IOException e) {
e.printStackTrace();
}
return bmpUri;
}
upewnij się, aby dodać odpowiednie uprawnienia do AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Przepełnienie stosu jest przeznaczone do programowania ** pytań **. To nie jest pytanie. Jeśli chcesz odpowiedzieć na własne pytanie, to jest w porządku, ale proszę ** zadaj pytanie **. [Dokumentacja witryny] (https://stackoverflow.com/help/self-answer) ma więcej informacji na temat odpowiedzi na własne pytania. – CommonsWare
Przykro mi .. Mam ten numer kilka godzin temu i nie mogę znaleźć odpowiedzi na stackowerflow, więc postanowiłem to naprawić –
Mój przyjaciel używa tego, ale udostępnił zły identyfikator obrazu, czy masz ten problem? Używa widoku firebaserecycler z Picasso –