是否可以与我的应用程序图标共享文本?
因为我尝试这样做但它适用于纯文本,但是当我尝试使用图像时,它会共享整个图像,但我只想要一个小缩略图。 这是我的实际代码:
Intent intent2=new Intent(Intent.ACTION_SEND);
intent2.setType("image/*");
intent2.putExtra(Intent.EXTRA_TEXT,random);
Uri path = Uri.fromFile(new File(Image));
intent2.putExtra(Intent.EXTRA_STREAM, path );
startActivity(Intent.createChooser(intent2, "Share via"));
答案 0 :(得分:0)
试试这段代码:
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));