Frage

I am using the new Facebook SDK 3.0 that just released on Android. I want to let the user invite his/her friends to the app.

However, in the new SDK you do NOT create a new Facebook object with the App ID. You extend the FacebookActivity as given in the tutorial: http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/

Hence, I could not use the reference material provided to send invites to friends since there is no facebook object to call the dialog method on. http://developers.facebook.com/docs/howtos/androidsdk/3.0/send-requests/

I've already setup the Friend Picker UI and can get GraphUser objects that the user selected. http:// developers(dot)facebook(dot)com/docs/tutorials/androidsdk/3.0/scrumptious/show-friends/

But, I can't figure out how to invite the friends that the user has selected.

Does anyone know how to invite friends in the new SDK? Would you be using the FbDialog class? If so, what is the url string that needs to be provided? (I tried using "apprequests", but that didn't work)

Thanks for your help.

War es hilfreich?

Lösung

You can use com.facebook.widget.WebDialog class for this:

WebDialog dialog = new WebDialog.Builder(myActivity, mySession, ...).build();
dialog.show();

Also see helper classes WebDialog.FeedDialogBuilder and WebDialog.RequestsDialogBuilder that make it easier to build these dialogs.

Andere Tipps

Try this link:

https://developers.facebook.com/docs/howtos/androidsdk/3.0/send-requests/

    private void sendRequestDialog() {
    Bundle params = new Bundle();
    params.putString("message", "Learn how to make your Android apps social");
    WebDialog requestsDialog = (
        new WebDialog.RequestsDialogBuilder(getActivity(),
            Session.getActiveSession(),
            params))
            .setOnCompleteListener(new OnCompleteListener() {

                @Override
                public void onComplete(Bundle values,
                    FacebookException error) {
                    final String requestId = values.getString("request");
                    if (requestId != null) {
                        Toast.makeText(getActivity().getApplicationContext(), 
                            "Request sent",  
                            Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity().getApplicationContext(), 
                            "Request cancelled", 
                            Toast.LENGTH_SHORT).show();
                    }
                }

            })
            .build();
    requestsDialog.show();
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top