【问题标题】:Unable to share image link via whatsapp无法通过 whatsapp 分享图片链接
【发布时间】:2018-04-29 18:30:57
【问题描述】:

实际上,我在我的应用程序中提供了一个共享选项,可以通过引用this link 将图片分享给whatsapp,但它不起作用。它正在像Share failded please try again 这样的东西敬酒。谁能帮我解决这个问题。

代码:

String image_url = "http://images.cartradeexchange.com//img//800//vehicle//Honda_Brio_562672_5995_6_1438153637072.jpg";

    Intent shareIntent = new Intent();
    shareIntent.setType("image/*");
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, image_url);
            // Target whatsapp:
    shareIntent.setPackage("com.whatsapp");
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            try {
                startActivity(shareIntent);
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(InventoryManageOnlineActivity.this,
                        "Whatsapp have not been installed.",
                        Toast.LENGTH_SHORT).show();
            }

【问题讨论】:

    标签: android android-intent whatsapp


    【解决方案1】:

    您正在尝试将该 URL 共享为文本。所以使用:

    shareIntent.setType("text/plain");
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-15
      • 1970-01-01
      • 2013-03-07
      • 1970-01-01
      相关资源
      最近更新 更多