【发布时间】:2015-03-06 07:13:24
【问题描述】:
我的问题是如何将位图发送到 Whastapp 应用程序并使用以下代码;
ImageView iv=(ImageView)view.findViewById(R.id.item_image);
Bitmap bitmap = ((BitmapDrawable)iv.getDrawable()).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.setType("image/png");
waIntent.putExtra(Intent.ACTION_SEND, byteArray);
startActivity(Intent.createChooser(waIntent, "Share with"));
但该代码不起作用。我的错误是什么?谢谢。
【问题讨论】:
-
您可以使用
putParcelable()将Bitmap直接放入Intent的Bundle中 -
@abforce 你能举个例子吗