【发布时间】:2018-10-29 01:23:06
【问题描述】:
我想通过信使从我的应用程序发送图像。我在查看 Stack Overflow 时发现 answer 适用于 WhatsApp。当我尝试将“com.whatsapp”更改为“com.facebook.orca”时,它停止工作。这是我的代码:
public void shareImageMessenger() {
Bitmap adv = BitmapFactory.decodeResource(getResources(), R.drawable.koza);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
adv.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "temporary_file_1.jpg");
try {
f.createNewFile();
new FileOutputStream(f).write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse( Environment.getExternalStorageDirectory()+ File.separator+"temporary_file_1.jpg"));
share.setPackage("com.facebook.orca");
startActivity(Intent.createChooser(share, "Share Image"));
}
【问题讨论】:
-
错误是什么
-
出了点问题!请稍后再试!或者它只是加载而没有任何反应。
-
logcat崩溃时检查一下..或者尝试抛出异常,以便我们知道问题所在然后解决它
-
您在执行此操作的设备上是否安装了 messenger?
-
是的,我有。我会尽快处理的,谢谢。
标签: java android facebook-messenger