通过分享在Facebook意向的文本,不使用Facebook的SDK [英] Share text via Intent on Facebook without using Facebook sdk

查看:319
本文介绍了通过分享在Facebook意向的文本,不使用Facebook的SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Facebook并没有允许通过意向共享文本,除非我们使用Facebook SDK,我正在寻找一种方式围绕实现这一目标。

As Facebook doesn't allow sharing text via Intent unless we use Facebook sdk, I am looking for a way around to achieve this.

我能想到的3黑客,我可以使用:

I can think of 3 hacks which I can use:

1)由于Facebook允许图像共享,我可以生成绘制到它位图与共享文本,并使用将影像分享的意图

1) As Facebook allows image sharing, I can generate a Bitmap with sharing text drawn onto it and share the image using Intent.

2)Facebook允许共享的URL,为此它也显示了页面,同时分享。我可以在我的服务器上托管专用页面,并通过在url值作为参数,并生成使用它(我用php没有经验,但我想这一点。是可能的)

2) Facebook allows sharing URLs, for which it also displays the Head of the page while sharing. I can host a dedicated page on my server and pass values as parameter in the url, and generate the Head using it.(I have no experience with php, but I guess this is possible)

3)将文本复制到剪贴板,并通知用户这个问题。

3) Copy text to clipboard and notify user about this.

使用的所有3的组合。

任何人都可以建议我一个更好的办法解决大家分享我在Facebook上的内容不使用Facebook的SDK?

Can anyone suggest me a much better way around to share my content on Facebook without using Facebook sdk?

先谢谢了。

推荐答案

这code,您可以粘贴只在Facebook上的内容。
什么ID要做的就是让手机中的所有应用程序present的列表,如果是找到空位然后打开Facebook的应用程序已经present

This code lets you paste your content on only on facebook. what id do is get the list of all apps present in your phone and find the open then open facebook app if is already present

        Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text to be shared");
        PackageManager pm = getPackageManager();
        List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
        for (final ResolveInfo app : activityList) {
            if ((app.activityInfo.name).contains("facebook")) {
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                shareIntent.setComponent(name);
                startActivity(shareIntent);
                break;
           }
        }

这篇关于通过分享在Facebook意向的文本,不使用Facebook的SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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