如何使用意图在pinterest上共享图像和文本 [英] How to share image and text on pinterest using intent

查看:135
本文介绍了如何使用意图在pinterest上共享图像和文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用意图在pinterest上共享图像和文本.有什么想法吗?

I want to share image and text on pinterest using intent. Any ideas?

推荐答案

您必须首先检查pintrest应用程序是否已安装到设备中或未使用此功能.

You have to first check pintrest application is installed into device or not using this function.

    private boolean appInstalledOrNot(String uri) {
       PackageManager pm = getPackageManager();
       boolean app_installed;
       try {
           pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
           app_installed = true;
       }
       catch (PackageManager.NameNotFoundException e) {
           app_installed = false;
       }
       return app_installed;
   }

如果此函数返回true,则可以在下面的行中调用它.

If this function returns you true than you can call this below line.

File imageFileToShare = new File(orgimagefilePath);

Uri uri = Uri.fromFile(imageFileToShare);

Intent sharePintrestIntent = new Intent(Intent.ACTION_SEND);
sharePintrestIntent.setPackage("com.pinterest");
sharePintrestIntent.putExtra("com.pinterest.EXTRA_DESCRIPTION", text);
sharePintrestIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharePintrestIntent.setType("image/*");
startActivityForResult(sharePintrestIntent, PINTEREST);

这对我来说很有效.请检查一下.

This was work for me. please check it.

这篇关于如何使用意图在pinterest上共享图像和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆