How to share image and text on pinterest using intent

谁说我不能喝 提交于 2019-12-25 09:24:49

问题


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


回答1:


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;
   }

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.



来源:https://stackoverflow.com/questions/40560331/how-to-share-image-and-text-on-pinterest-using-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!