Reputation: 804
I am using Android SDK v3.0 for Facebook to send requests to friends for using my app. I've used the code I saw on here to open up Facebook's Dialog app and make a request to the user's friends.
After using the following code to display and send the request. I now get a "Request Sent" toast but the request is never sent.
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("message", "MESSAGE");
params.putString("app_id", "APPID");
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 FacebookException) {
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();
}
The following log is obtained from Logcat during the display of Request Dialog :
03-15 17:18:51.944: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:18:53.759: V/chromium(2842): external/chromium/net/base/bandwidth_metrics.h:96: [0315/171853:INFO:bandwidth_metrics.h(96)] Bandwidth: 1500.13Kbps (avg 2275.13Kbps)
03-15 17:18:54.124: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:18:58.019: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:18:58.629: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:18:58.684: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:18:59.314: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:18:59.369: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:18:59.949: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:18:59.954: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:19:00.534: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:19:00.539: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:19:01.329: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:19:03.459: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:19:03.984: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:19:04.019: W/dalvikvm(2842): disableGcForExternalAlloc: true
03-15 17:19:04.189: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:19:06.269: W/dalvikvm(2842): disableGcForExternalAlloc: false
03-15 17:19:10.869: I/NONPRIME(2842): <CallBackProxy> Send to WebViewClient.
Please point me in the right direction...
Upvotes: 1
Views: 1257
Reputation: 1389
In app setting in facebook developer account add a canvas framework and after that add below code to send app request. if in activity replace getActivity() with YourActivityName.this if in fragment no need to replace anything
Bundle params = new Bundle();
params.putString("message",
"Join CConnect To feel Better Experience Of Meetings And Calls");
WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
getActivity(), Session.getActiveSession(), params))
.setTheme(
android.R.style.Theme_Translucent_NoTitleBar_Fullscreen))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(
getActivity()
.getApplicationContext(),
"Request cancelled",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(
getActivity()
.getApplicationContext(),
"Network Error", Toast.LENGTH_SHORT)
.show();
}
} else {
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();
Upvotes: 0
Reputation: 4794
From this Facebook developers page: "User to User Requests are only available for Canvas apps"
Upvotes: 2