Facebook Login & Share in Android

Facebook Login & Share  in Android
---------------------------------------
We can share a content in facebook using two ways
1:using intent share
2:using facebook sdk
Using Facebook SDK
------------------
------------------
To share a content, facebook sdk is required
first of all we need to include facebook jar to our project
if it shows error,create folder(like com->facebbok->android ) and place all files inside it.In this way we can access it in project.
We need APPID for sharing the post.It is given by facebook while registering the app.
Facebook SDK contains facebook.java,AsyncFacebookRunner.java  etc
-----------------------------------------------------------------
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
if (!facebook.isSessionValid()) {
login();
}
else {
mAsyncRunner.request("me", new IDRequestListener());
}
public void login() {
facebook.authorize(FaceBookAuthentication.this, PERMISSIONS,new LoginDialogListener());
}
class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
mAsyncRunner.request("me", new IDRequestListener());
}
// Getting User values from Facebook
// -----------------------------------------
private class IDRequestListener implements RequestListener {
@Override
public void onComplete(String response, Object state) {
try {
JSONObject json = Util.parseJson(response);
int fbID = json.getInt("id");
String fbFullName = json.getString("name");
String fbLastName = json.getString("last_name");
FaceBookAuthentication.this.runOnUiThread(new Runnable() {
public void run()
{
// HERE you can save the user values in shared preference-------------------
---For later authentication purpose
}
});
} catch (JSONException e) {
Log.d("TAG", "JSONException: " + e.getMessage());
} catch (FacebookError e) {
Log.d("TAG", "FacebookError: " + e.getMessage());
}
}
By doing,this much..a user can login using facebook
Next is how to share a content
------------------------------
------------------------------
Inorder to share ,user signin is required..So do the above process.
After that,
----------------------------------------------------------------------------
public void postToWall(String message) {
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
Bundle parameters = new Bundle();
parameters.putString("message", a);
parameters.putString("attachment",
"{\"name\":\"Name\","
+ "\"href\":\"" + "website url" + "\","
+ "\"description\":\""content"\","
+ "\"media\":[{\"type\":\"image\",\"src\":\""
+ "image url"
+ "\",\"href\":\"" + "http://www.google.com" + "\"}]"
+ "}");
facebook.dialog(ShareOnFacebook.this, "stream.publish", parameters,
new wallPostWithLoginAuth());
}
class  wallPostWithLoginAuth implements DialogListener {
@Override
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
showToast("Message posted to your facebook wall!");
finish();
}
----------------------------------After this your share will be appeared in facebook.....................