【发布时间】:2014-08-19 09:02:27
【问题描述】:
我有一个可以通过 WhatsApp 共享图像的工作应用程序。我使用mime type 将所选图像重定向到 WhatsApp。
但是,当从聊天/WhatsApp 中选择图像附件并选择我的应用程序后,它会从 WhatsApp 中的各种联系人列表重新开始。
我想要的是使用我的应用程序直接在聊天框中分享图像。 这里请理解:
选择附件时
定向到应用主页
随机选择图片并分享到whatsapp
但它会发送给联系人和群组,而不是聊天框:(
这是我的分享代码:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
ImageView image = (ImageView) findViewById(R.id.full_image_view);
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
File sd = Environment.getExternalStorageDirectory();
String fileName = "desi.png";
File dest = new File(sd, fileName);
try {
FileOutputStream out;
out = new FileOutputStream(dest);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
switch (item.getItemId()) {
case R.id.item:
Uri uri = Uri.fromFile(dest);
Intent shareIntent = new Intent();
shareIntent.setPackage("com.whatsapp");
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share)));
return true;
【问题讨论】:
标签: android android-intent share mime-types