試試這個適配器:
viewHolder.img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//here write code to share image //get clicked image bitmap and then share
Bitmap bitmap = ((BitmapDrawable)viewHolder.img.getDrawable()).getBitmap();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/png");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap , "Title", null);
// Uri uri = Uri.parse("android.resource://your package
//name/"+R.drawable.ic_launcher);
Uri uri = Uri.parse(path);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello, This is test Sharing");
startActivity(Intent.createChooser(shareIntent, "Send your image"));
}
});
我看到了你的代碼。它沒有'ShareActionProvider'的任何部分。閱讀關於android在這裏共享https://github.com/codepath/android_guides/wiki/Sharing-Content-with-Intents –
沒有錯誤。我想知道我該怎麼做。我不知道。 –