send an invite through android application to facebook friends

后端 未结 1 672
深忆病人
深忆病人 2021-02-06 17:26

How to send an invitation to facebook friends through my App on Android..

相关标签:
1条回答
  • 2021-02-06 17:44

    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

    0 讨论(0)
提交回复
热议问题