在Facebook上墙位图图像共享 [英] Bitmap image sharing on Facebook wall
问题描述
我要像标题,描述上的Facebook墙上的一些细节分享我的应用程序的屏幕截图。请任何一个可以帮助我,我该怎么办呢?我想用facebookSDK。如果可共享的任何其他选项,请帮助我。
I want to share screenshot of my application screen with some details like title,description on facebook wall. Please any one can help me how can i do this? I want to use facebookSDK. If any other options available for sharing please help me.
推荐答案
您可以简单地做,没有使用Facebook的SDK安装在手机的Facebook应用程序的帮助。只要遵循这些简单的步骤
You can simply do that without using Facebook SDK with the help of facebook app installed in your phone. Just follow these simple steps
所以,首先,你得把你的应用程序的截图在这样的位图的形式
So first of all, you have to take screenshot of your app in the form of bitmap like this
View v1 = yourScreenShotView.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap= v1.getDrawingCache();
在你从上面然后得到位图你必须做出这样的位图的URI
After you get bitmap from above then you have to make uri of the bitmap like this
uri = getImageUri(context, bitmap);
和这里是你的getImageUriFunction()
and here is your getImageUriFunction()
public static Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(),
inImage, "", "");
return Uri.parse(path);
}
在您得到您的URI,你要使用该功能分享的FB
After you get your uri, you have to share that on fb with this function
share_screen(uri,"facebook");
下面是功能
public void share_screen(Uri pngUri, final String sharingapp) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent
.putExtra(android.content.Intent.EXTRA_TEXT,
"your sharing text");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri); // Share
// the
// image
// on
// Facebook
PackageManager pm = getApplicationContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent,
0);
for (final ResolveInfo app : activityList) {
if ((app.activityInfo.name).contains(sharingapp)) {
c++;
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(
activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setComponent(name);
startActivity(shareIntent);
break;
}
}
if (c == 1)
c = 0;
else {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
context);
alertDialog.setTitle("Alert");
alertDialog.setMessage("You don't have " + sharingapp
+ " installed.");
alertDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
}
}
我只是从我的项目的一个拷贝,所以希望您能理解.. !!
I am just copying it from one of my project, so hope you will understand..!!
这篇关于在Facebook上墙位图图像共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!