Post on facebook wall in android?
In the Android Gallery in the phone there is an option to share the image to facebook and post it on the wall .I want to post a message or an image on to the wall in the exactly similar way from my app.How can this be done?
My understanding :I believe that it uses facebook app already present in my phone.If that's the case then i can start that particular activity or throw an intent corresponding to that activity from my app.If this is the case can someone let me know what is the corresponding intent that i should be throwing. What are the parameters that i should be passing in the intent and under what keyname should i pass these parameters?
Correct me if my understanding is wrong and let me know how this can be done.
PS :I have been using the facebook sdk according to this wonderful post Android/Java -- Post simple text to Facebook wall? and it works.But the dialogs don't look that good.That's why i am looking for a different option.
Thanks
I think you are looking for the ACTION_SEND intent.
See this post.
Edit: and its doc
Second edit: note that if the guy does not have the Facebook app, he won't be able to share. If you use the Facebook API, then he will be able to share to facebook, but facebook only.
For a long time research. Finally i found out the solution..
it's works for me very well.
private void postToFacebookViaIntent() {
File mFile = new File(Environment.getExternalStorageDirectory()+ "/images.jpg");
Intent shareIntent = findFacebookClient();
if (shareIntent != null && mFile!= null) {
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(mFile));
startActivity(Intent.createChooser(shareIntent, "Share"));
} else {
Toast.makeText(SharingActivity.this, "Facebook App is not installed", Toast.LENGTH_SHORT).show();
}
}
private Intent findFacebookClient() {
final String twitterApps = "facebook";
Intent facebookIntent = new Intent();
facebookIntent.setAction(Intent.ACTION_SEND);
facebookIntent.setType("image/jpeg");
final PackageManager packageManager = getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(
facebookIntent, 0);
for (ResolveInfo resolveInfo : list) {
String p = resolveInfo.activityInfo.packageName;
if (p != null && p.contains(twitterApps)) {
facebookIntent.setPackage(p);
return facebookIntent;
}
}
return null;
}
This article can help you solver this problem. http://vnstep.wordpress.com/2012/04/14/share-via-android/ or Share Text on Facebook from Android App via ACTION_SEND
链接地址: http://www.djcxy.com/p/49604.html