Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to register callback of App Invite Dialogue

This is my code working fine.I am am getting invitaton. All of the code working .

Q)How to show log messages of callback.

Q) Why I can not get log messages in logcat.

if (AppInviteDialog.canShow()) {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(AppURl)
                .build();

        AppInviteDialog appInviteDialog = new AppInviteDialog(getActivity());
        appInviteDialog.registerCallback(sCallbackManager,
                new FacebookCallback<AppInviteDialog.Result>() {
                    @Override
                    public void onSuccess(AppInviteDialog.Result result) {
                        Log.d("Invitation", "Invitation Sent Successfully");
                        Toast.makeText(getActivity(), "Invitation Sent Succseesfully", Toast.LENGTH_LONG).show();

                    }

                    @Override
                    public void onCancel() {
                        Log.d("Invitation", "Invitation Cancel Successfully");
                    }

                    @Override
                    public void onError(FacebookException e) {
                        Log.d("Invitation", "Error Occured");
                    }
                });

        appInviteDialog.show(content);
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    sCallbackManager.onActivityResult(requestCode, resultCode,data);


}

Note : I also register callback in OnActivitResutl.

Please Suggest Something If Question is Wrong. I am new on Stackoverflow.

Edit

When i use same code with Activity it works but when I use Fragment It does not work. Why any explanation or code error ?

like image 420
nafees ahmed Avatar asked Aug 31 '15 04:08

nafees ahmed


1 Answers

Try to pass "FragmentName.this" instead of "getActivity" if you registering it from the fragment.

AppInviteDialog appInviteDialog = new AppInviteDialog(this);
like image 105
Nikita Axyonov Avatar answered Oct 21 '22 04:10

Nikita Axyonov