je dois partager, une URL de l'image externe avec texte, d'une WebView, mais pour une raison quelconque, je reçois des erreurs sur redéfinissent Picasso:Android - Partage d'images url + texte en utilisant Picasso
déjà mis en œuvre la Interface Javascript dans Android
@JavascriptInterface
public void shareContent(String text, String imageURL){
shareData(text, imageURL);
}
erreur que je reçois:Method does not override method from its superclass
.
public void shareData(String url) {
Picasso.with(getApplicationContext()).load(url).into(new AppLink.Target() {
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/*");
i.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bitmap));
startActivity(Intent.createChooser(i, "Share Image"));
}
@Override public void onBitmapFailed(Drawable errorDrawable) { }
@Override public void onPrepareLoad(Drawable placeHolderDrawable) { }
});
}
Et la méthode pour obtenir l'image enregistrée locale
public Uri getLocalBitmapUri(Bitmap bmp) {
Uri bmpUri = null;
try {
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "share_image_" + System.currentTimeMillis() + ".png");
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;
}
Comment n'est-ce pas un doublon? https://stackoverflow.com/questions/23681177/picasso-load-image-from-filesystem –
Je suis. Vous lisez un fichier à partir du disque, puis appelez une intention de partage. Pas sûr pourquoi Picasso est même nécessaire ici –
Pour la performance. – Isabelle