Android : Facebook Logout - android

I have a LoginViaFacebook Acitivity and a login button for facebook Login.I use the following code to login to facebook
private String[] permissions = {"publish_stream",
"read_stream", "user_photos", "publish_checkins", "photo_upload",
"email", "user_birthday" };
if (access_token != null) {
Utility.fb.setAccessToken(access_token);
token = access_token;
Log.e("OnCretae Facebook Token------------", token);
}
if (expires != 0) {
Utility.fb.setAccessExpires(expires);
}
btn_login.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if (CheckInternet.checkConn(LoginViaFacebook.this)) {
Utility.fb.authorize(LoginViaFacebook.this, permissions,
new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
"onFacebookError",
Toast.LENGTH_LONG).show();
Log.e("Sajolllllllllllllllll", e + "");
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
"onError", Toast.LENGTH_LONG)
.show();
Log.e("Sajolllllllllllllllll", e + "");
}
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
editor = sp.edit();
token = Utility.fb.getAccessToken();
Log.e("Token---------", token);
editor.putString("access_token",
Utility.fb.getAccessToken());
editor.putLong("access_expires",
Utility.fb.getAccessExpires());
editor.commit();
Toast.makeText(getApplicationContext(),
"Login Successful",
Toast.LENGTH_LONG).show();
mProgress = ProgressDialog.show(
LoginViaFacebook.this, "",
"Please Wait...", true);
Thread t = new Thread(retriveProfileData);
t.start();
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
"onCancel", Toast.LENGTH_LONG)
.show();
}
});
}
}
});
I save the access token to login next time directly if user not logout
I have another activity namely Settings and have button Logout.I use following code to logout from facebook
lagoutLayout.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
final String[] items = new String[] { "Yes", "No" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
SettingsActivity.this,
android.R.layout.select_dialog_item, items);
AlertDialog.Builder builder = new AlertDialog.Builder(
SettingsActivity.this);
builder.setTitle("Select Option");
builder.setAdapter(adapter,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) { // pick
// from
// camera
if (item == 0) {
try {
editor.remove("FacebookId");
editor.remove("EmailId");
editor.commit();
Log.e("Pre----------------", sp1
.getString("access_token", "d"));
editor1.remove("access_token");
editor1.remove("access_expires");
editor1.commit();
Log.e("After----------------", sp1
.getString("access_token", "d"));
Log.e("DATATTAT--------",
sp.getString("FacebookId",
"saf")
+ " "
+ sp.getString(
"EmailId", "as"));
String r = Utility.fb
.logout(SettingsActivity.this);
Log.e("Res-----------", r);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else { // pick from file
dialog.dismiss();
}
}
});
dialog = builder.create();
dialog.show();
}
});
The response from Facebook Logout method show true in Log.
But when i again run application it will automatically login to facebook
I can'nt find out the problem.Please help me

I use this code and it worked fine
public void logout() {
if (!isConnected(activity)) {
Toast.makeText(activity, "Internet not connected", Toast.LENGTH_LONG).show();
return;
}
SessionEvents.onLogoutBegin();
AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(this.facebook);
asyncRunner.logout(this.context, new LogoutRequestListener());
}
And here is the listener
public class LogoutRequestListener extends BaseRequestListener {
public void onComplete(String response, final Object state) {
// callback should be run in the original thread,
// not the background thread
mHandler.post(new Runnable() {
public void run() {
SessionEvents.onLogoutFinish();
Intent intent= new Intent(activity,Login.class);
activity.startActivity(intent);
activity.finish();
}
});
}
}

For facebook sdk version 3 above
public void logoutFacebook() {
Session session = Session.getActiveSession();
if(session != null && session.isOpened()){
session.closeAndClearTokenInformation();
}
}

if you are extending and using facebook openSession when logging you must close it using closeSession and put it in your logout or you can simply put it onDestroy just like this
public void onDestroy() {
this.closeSession();
super.onDestroy();
}

Try this :
I hope this will be help to you...
if (mFacebook.isSessionValid()) {
try {
String str = mFacebook.logout(getApplicationContext());
SessionStore.clear(getApplicationContext());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

If you are viewing this answer from google suggestion and using facebook sdk v4 or above, just use this lines. It works perfectly.
if (AccessToken.getCurrentAccessToken() != null) {
LoginManager.getInstance().logOut();
}

Related

How to get Facebook data in my Android app [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am developing one Android app in which there are two activities.
First activity: With button to go onto Facebook already login page. I want to know how to fetch data (like Name, DOB, Place, Email ID) from Facebook into my app.
Second activity (with EditText): How to match there API or what is required please let me know. I searched everywhere but did not find any answer.
I have done this, but it is showing errors.
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_facebook);
facebook = (Button) findViewById(R.id.facebook);
facebook.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
onClickFacebookLogin();
// Intent in = new Intent(FacebookActivity.this,GetDataFromFacebook.class);
// in.putExtra("email", );
// startActivity(in);
}
});
}
public void onClickFacebookLogin() {
// Session.openActiveSession(this, true, new Session.StatusCallback() {
openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
#Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
// ((GlobalFilename)Login.this.getApplication()).setfbSession(session);
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
#Override
public void onCompleted(GraphUser user,
Response response) {
// TODO Auto-generated method stub
if (user != null) {
final GraphUser graphuser=user;
try{
new AsyncTask<Void, Void, Void>() {
String fbemail,fname,lname,mediaid,image_url,gender,dob;
ProgressDialog progressDialog;
ImageLoader imageLoader;
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MyAccount.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
#Override
protected Void doInBackground(Void... params) {
Object g = graphuser.asMap().get("email");
if(g==null)
{
fbemail="";
fname=graphuser.getFirstName();
lname=graphuser.getLastName();
mediaid=graphuser.getId();
System.out.println("===>accountname inside null"+fbemail);
return null;
}
else{
fbemail= graphuser.asMap().get("email").toString();
gender =graphuser.asMap().get("gender").toString();
image_url = "https://graph.facebook.com/"+graphuser.getId()+"/picture?type=square";
// image_url=String.format(image_url);
//accountName =graphuser.getProperty("email").toString();
System.out.println("fb email====>"+fbemail);
fname=graphuser.getFirstName();
lname=graphuser.getLastName();
mediaid=graphuser.getId();
dob=graphuser.getBirthday();
System.out.println("Gender"+gender);
System.out.println("Image==>"+image_url);
try {
InputStream in = new java.net.URL(image_url).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
if(mIcon11==null)
{
System.out
.println("null in doinbackground");
}
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
//Toast.makeText(getApplicationContext(), userid, Toast.LENGTH_LONG).show();
System.out.println("fb email====>"+fbemail);
//Toast.makeText(getApplicationContext(), accountName, Toast.LENGTH_LONG).show();
return null;
}
}
#Override
protected void onPostExecute(Void v) {
super.onPreExecute();
progressDialog.dismiss();
tvname.setText(fname+" "+lname);
tvemail.setText(fbemail);
imageLoader = new ImageLoader(MyAccount.this);
System.out
.println("imageurlonpost==>"+image_url);
// imageLoader.DisplayImage(image_url,fbprofileimage);
if (mIcon11 != null
){
// do what you need to do with the bitmap :)
fbprofileimage.setImageBitmap(mIcon11);
}
else{
Toast.makeText(MyAccount.this,"Null",Toast.LENGTH_LONG).show();
}
}
}.execute();
}catch(Exception e) {
//findViewById(R.id.progressbar).setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "Facebook configuration error!", Toast.LENGTH_LONG).show();
}
}
}
});
}
}
},Arrays.asList("email"));
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
Showing errors at new Session.StatusCallback()(under onClickFacebookLogin()) & getActiveSession() (at onActivityResult)
Here is the complete working code.Set up your developer account and call this method.Also dont forget to call onActivityResult() once the control return from facebook.
//Method invoked when facebook login button is clicked
public void onClickFacebookLogin() {
// Session.openActiveSession(this, true, new Session.StatusCallback() {
openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
#Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
// ((GlobalFilename)Login.this.getApplication()).setfbSession(session);
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
#Override
public void onCompleted(GraphUser user,
Response response) {
// TODO Auto-generated method stub
if (user != null) {
final GraphUser graphuser=user;
try{
new AsyncTask<Void, Void, Void>() {
String fbemail,fname,lname,mediaid,image_url,gender,dob;
ProgressDialog progressDialog;
ImageLoader imageLoader;
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MyAccount.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
#Override
protected Void doInBackground(Void... params) {
Object g = graphuser.asMap().get("email");
if(g==null)
{
fbemail="";
fname=graphuser.getFirstName();
lname=graphuser.getLastName();
mediaid=graphuser.getId();
System.out.println("===>accountname inside null"+fbemail);
return null;
}
else{
fbemail= graphuser.asMap().get("email").toString();
gender =graphuser.asMap().get("gender").toString();
image_url = "https://graph.facebook.com/"+graphuser.getId()+"/picture?type=square";
// image_url=String.format(image_url);
//accountName =graphuser.getProperty("email").toString();
System.out.println("fb email====>"+fbemail);
fname=graphuser.getFirstName();
lname=graphuser.getLastName();
mediaid=graphuser.getId();
dob=graphuser.getBirthday();
System.out.println("Gender"+gender);
System.out.println("Image==>"+image_url);
try {
InputStream in = new java.net.URL(image_url).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
if(mIcon11==null)
{
System.out
.println("null in doinbackground");
}
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
//Toast.makeText(getApplicationContext(), userid, Toast.LENGTH_LONG).show();
System.out.println("fb email====>"+fbemail);
//Toast.makeText(getApplicationContext(), accountName, Toast.LENGTH_LONG).show();
return null;
}
}
#Override
protected void onPostExecute(Void v) {
super.onPreExecute();
progressDialog.dismiss();
tvname.setText(fname+" "+lname);
tvemail.setText(fbemail);
imageLoader = new ImageLoader(MyAccount.this);
System.out
.println("imageurlonpost==>"+image_url);
// imageLoader.DisplayImage(image_url,fbprofileimage);
if (mIcon11 != null
){
// do what you need to do with the bitmap :)
fbprofileimage.setImageBitmap(mIcon11);
}
else{
Toast.makeText(MyAccount.this,"Null",Toast.LENGTH_LONG).show();
}
}
}.execute();
}catch(Exception e) {
//findViewById(R.id.progressbar).setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "Facebook configuration error!", Toast.LENGTH_LONG).show();
}
}
}
});
}
}
},Arrays.asList("email"));
}

How to Show message from Runnable to the MainActivity

I am using the external library SignalR, and I find the Github code in Java I have implemented it successfully and receiving the Log messages such as Connected , Message etc but when I tries to show these messages in the MainActivity EditText and textviews , it is really not working . Following is a code that I modified according to my need now tell me how to modify accordingly in android to receive the messages on Ui.
public class HubClient {
public HubProxy RelayServerHubProxy;
MainActivity mainActivity = new MainActivity();
public HubConnection RelayServerHubConnection;
Context context = null;
public Boolean Connected = false;
public static String ErrorName,ConnectionStatus,MessageReceived;
Logger logger = new Logger() {
#Override
public void log(String message, LogLevel level) {
// TODO Auto-generated method stub
// System.out.println(message);
Log.v("Message Received in Logger", message);
}
};
public HubClient(Context context) {
this.context = context;
mainActivity = new MainActivity();
}
public void Connect(String ServerURI, String SockConnectionType) {
try {
ClientTransport webSockTransport = null;
RelayServerHubConnection = new HubConnection(ServerURI);
// creating hub prox object
RelayServerHubProxy = RelayServerHubConnection
.createHubProxy("MyHub");
// Start the connection
RelayServerHubConnection.start().done(new Action<Void>() {
#Override
public void run(Void obj) throws Exception {
// TODO Auto-generated method stub
Log.v("Connection Status", "Connection done");
}
});
// Subscribe to the error event
RelayServerHubConnection.error(new ErrorCallback() {
public void onError(Throwable error) {
// TODO Auto-generated method stub
error.printStackTrace();
Log.v("WE've GOt erroe", error.getMessage());
ErrorName = error.getMessage();
//mainActivity.ShowToast(error.getMessage());
}
});
// Subscribe to the connected event
RelayServerHubConnection.connected(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
Log.v("Connected", "Connected");
Connected = true;
// Toast.makeText(mainActivity, "Connected",
// Toast.LENGTH_LONG).show();
}
});
// Subscribe to the closed event
RelayServerHubConnection.closed(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
Log.v("Connection is", "Closed");
}
});
RelayServerHubProxy.subscribe(new Object() {
#SuppressWarnings("unused")
public void messageReceived(String name, String message) {
Log.v("Server Message", name + message);
// Toast.makeText(context, message,
// Toast.LENGTH_LONG).show();
MessageReceived = name+message;
}
});
// Subscribe to the received event
RelayServerHubConnection.received(new MessageReceivedHandler() {
#Override
public void onMessageReceived(JsonElement json) {
//how to show this message on again mainactivity Textview
Log.v("onMessagReceived", json.toString());
}
});
RelayServerHubConnection.stateChanged(new StateChangedCallback() {
#Override
public void stateChanged(ConnectionState oldState,
ConnectionState newState) {
// TODO Auto-generated method stub
if (newState == microsoft.aspnet.signalr.client.ConnectionState.Connected)
{
// how to show Connected status in Textview?
} else if (oldState == microsoft.aspnet.signalr.client.ConnectionState.Disconnected) {
// Show Message here
}
}
});
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void SendMessageToServer(String messageToServer1) {
try {
RelayServerHubProxy.invoke("MessageFromClient",
(String) messageToServer1);
RelayServerHubConnection.error(new ErrorCallback() {
public void onError(Throwable error) {
// TODO Auto-generated method stub
error.printStackTrace();
//How to show message of error on Main Activity ?
}
});
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
Log.v("Exception", e.toString());
}
}
}
Now I have commented what I want in the functions. Notice that All function is using Runnable . So please tell me how to modify this to use in android
To show an alertDialog paste this function in your HubClient object:
private void showError(final String message) {
((Activity)context).runOnUiThread(new Runnable() {
public void run() {
new AlertDialog.Builder(context)
.setTitle("Error")
.setMessage(message)
.setPositiveButton("Ok", null)
.show();
}
});
}
You can call it inside your error callback
To show a message in a TextView use this one:
private void updateTextView(final String message) {
((Activity)context).runOnUiThread(new Runnable() {
public void run() {
// mTextView must be referenced by HubClient
mTextView.setText(message);
}
});
}

facebook api with android

I am new to facebook api and android.But somehow try to manage login to my facebook account and retrieve some information of my account i.e. id,first_name,last_name.The sdk(android) which is used on creating this application is sdk(android) level 8 but when i used sdk(android) level >8 application crash and error generate on logcat(networkonmainthreadException).I had done some search and found this is thread problem with sdk level and now i am going for Asynctask but got confused where to put the login code for facebook and what thing will return to mainactivity
My code for sdk level 8 is:-
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
loginnfetch=(Button) findViewById(R.id.button1);
loginnfetch.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
facebook=new Facebook(APP_ID);
restorecredential(facebook);
if(!facebook.isSessionValid())
{
loginandfetch();
}
else
{
fetch();
}
}
});
}
protected void fetch()
{
try {
JSONObject jobj=new JSONObject(facebook.request("me"));
int id=jobj.getInt("id");
String fname=jobj.getString("first_name");
String lname=jobj.getString("last_name");
//String emailid=jobj.getString("email");
Toast.makeText(getApplicationContext(), ".."+id+".."+fname+".."+lname, 0).show();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
protected void loginandfetch()
{
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,new DialogListener() {
#Override
public void onFacebookError(FacebookError e)
{
Toast.makeText(getApplicationContext(), "ERROR WHILE LOGIN", 0).show();
}
#Override
public void onError(DialogError e) {
Toast.makeText(getApplicationContext(), "ERROR WHILE LOGIN", 0).show();
}
#Override
public void onComplete(Bundle values) {
saveCredentials(facebook);
fetch();
}
#Override
public void onCancel() {
Toast.makeText(getApplicationContext(), "ERROR WHILE LOGIN", 0).show();
}
});
}
protected boolean restorecredential(Facebook facebook2)
{
SharedPreferences sharedPreferences = getApplicationContext()
.getSharedPreferences(KEY, Context.MODE_PRIVATE);
facebook.setAccessToken(sharedPreferences.getString(TOKEN, null));
facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES, 0));
return facebook.isSessionValid();
}
public boolean saveCredentials(Facebook facebook) {
Editor editor = getApplicationContext().getSharedPreferences(KEY,
Context.MODE_PRIVATE).edit();
editor.putString(TOKEN, facebook.getAccessToken());
editor.putLong(EXPIRES, facebook.getAccessExpires());
return editor.commit();
}
Please share some code if available or some link
thank you and sorry if something is not correct
From the ICS and above versions Android won't allowed any network operation in the UI thread.It should be done in separate thread so it won't hang the UI.Try your network communication code in the separate thread.
In your case,fetch facebook info using thread.
Try this ::
if(!facebook.isSessionValid())
{
new Thread(new Runnable() {
#Override
public void run() {
loginandfetch();
}
}).start();
}
else
{
new Thread(new Runnable() {
#Override
public void run() {
fetch();
}
}).start();
}
I have posted status on facebook like bellow. you can try something like this for your problem: (Facebook api 3.02b)
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(context, "Failed to Post", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context, "Successfully Posted", Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, victimId+"/feed", bundle,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

Facebook Android SDK, posting feed through feed dialog by defining predefined content

Its strange that I am using right code to make dialog with predefined content. But it isn't working :( guide me if I am wrong, thanks
Code:
Bundle params = new Bundle();
params.putString("message", "Predef Message");
Facebook facebook = new Facebook("APP_ID");
facebook.dialog(this, "feed", params, new DialogListener(){
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
#Override
public void onCancel() {
return;
}});
I found that we can't predefined a message for posting on wall, check this https://developers.facebook.com/docs/reference/androidsdk/dialog/ it requires user interaction
Message for Post on wall, Share a link or any else require user interaction. So a workaround is share a link and add description to it :)
Try this it is work for me
public void postfb() {
Log.i("PostFB", "POST FB ENTERED..!!");
Facebook facebook;
// facebook = new Facebook(InfrqncyApplication.APP_ID);
facebook = new Facebook(APP_ID);
// replace APP_API_ID with your own
facebook.authorize(getActivity(), new String[] { "publish_stream",
"offline_access" }, null);
Bundle params = new Bundle();
params.putString("link", imagePostPath);
params.putString("name", etxtTitle.getText().toString().trim());
// params.putString("caption","Via Sharesi.es");
params.putString("description", etxtDescription.getText().toString());
params.putString("picture", imagePostPath);
facebook.dialog(getActivity(), "stream.publish", params,
new DialogListener() {
#Override
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(getActivity(),
"Posted sucessfully !", Toast.LENGTH_SHORT)
.show();
AddPost();
} else {
Log.d("FB Sample App", "Canceled by User");
}
}
#Override
public void onFacebookError(FacebookError error) {
AddPost();
Log.e("fb", "fb error" + error);
}
#Override
public void onError(DialogError e) {
AddPost();
Log.e("fb", "fb dialog error" + e.getLocalizedMessage());
}
#Override
public void onCancel() {
AddPost();
}
});
}

send an invite through android application to facebook friends

How to send an invitation to facebook friends through my App on Android..
Here is how you can do it:
public void inviteFriends(Activity activity, ArrayList<FriendInfo> friendsIds){
// Safe programming
if(friendsIds == null || friendsIds.size() == 0)
return;
Bundle parameters = new Bundle();
// Get the friend ids
String friendsIdsInFormat = "";
for(int i=0; i<friendsIds.size()-1; i++){
friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(i) + ", ";
}
friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(friendsIds.size()-1).getId();
parameters.putString("to", friendsIdsInFormat);
parameters.putString( "message", "Use my app!");
// Show dialog for invitation
mFacebook.dialog(activity, "apprequests", parameters, new Facebook.DialogListener() {
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
}
});
}
Facebook dialog reference

Categories

Resources