Android使用intent在linkedIn上共享文本和图像

时间:2016-01-08 07:12:20

标签: android android-intent linkedin

我试图在LinkedIn上发送带有文字的图片作为帖子:

Intent linkedinIntent;
            String text1 = "...kaLis...";
            linkedinIntent = new Intent(Intent.ACTION_SEND);
            Uri path = Uri.parse(MediaStore.Images.Media.insertImage(activity.getContentResolver(),
                    BitmapFactory.decodeResource(activity.getResources(), R.drawable.logo), null, null));
            linkedinIntent.putExtra(Intent.EXTRA_STREAM, path);
            linkedinIntent.putExtra(Intent.EXTRA_TEXT, text1);
            linkedinIntent.setType("image/*");
            // linkedinIntent.setType("text/plain");
            boolean linkedinAppFound = false;
            List<ResolveInfo> matches2 = activity.getPackageManager()
                    .queryIntentActivities(linkedinIntent, 0);

            for (ResolveInfo info : matches2) {
                if (info.activityInfo.packageName.toLowerCase().startsWith(
                        "com.linkedin")) {
                    linkedinIntent.setPackage(info.activityInfo.packageName);
                    linkedinAppFound = true;
                    break;
                }
            }

            if (linkedinAppFound) {
                activity.startActivity(linkedinIntent);

            } else {
                Toast.makeText(activity, "LinkedIn app not Insatlled in your mobile", Toast.LENGTH_SHORT).show();
            }

但是这段代码只能一次发送一个东西。

0 个答案:

没有答案