Facebook is used by every individual in their normal life, so increasing the visibility of an android application or game is easily achieved if we send application invite to our facebook friends. If you are also looking for a code that send invites of the application to facebook friends than use the below.
After you logged in in Facebook,....just call this method ,this will automatically open a dialog and option to select friends for sending invitations..
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("title", "App Name");
params.putString("message", "hi i am using this app......(any text here)");
WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
LoginActivity.this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Network Error", Toast.LENGTH_SHORT)
.show();
}
} else {
final String requestId = values
.getString("request");
if (requestId != null) {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request sent", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
}
}
}
}).build();
requestsDialog.show();
}
After you logged in in Facebook,....just call this method ,this will automatically open a dialog and option to select friends for sending invitations..
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("title", "App Name");
params.putString("message", "hi i am using this app......(any text here)");
WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
LoginActivity.this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Network Error", Toast.LENGTH_SHORT)
.show();
}
} else {
final String requestId = values
.getString("request");
if (requestId != null) {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request sent", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
LoginActivity.this
.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
}
}
}
}).build();
requestsDialog.show();
}
0 comments:
Post a Comment