Reputation: 544
hi i am implementing the facebook share dialog for android sdk 3.5 however i am not getting any success im following the guides..
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(MyClass.this)
.setApplicationName("App Name")
.setName("Name")
.setLink("mylink")
.build();
i put this inside my on touch method there are no errors appearing but whenever i click the button.. nothing appears also~
is the MyClass.this wrong? thanks for reply~
Upvotes: 2
Views: 12219
Reputation: 1389
Please look at this: This is a useful link https://gist.github.com/jacklt/6700201
Upvotes: 0
Reputation: 16671
This is what Facebook recommends. I've just copied the code examples from this link where it is also explained how to handle the uiHelper
instance.
If you don't care about the results of the dialog it might be ok not to use the uiHelper.
Using the static method to check whether the dialog can be presented is prudent because it only initializes the builder and creates the dialog if it really is possible to present it.
if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
// Publish the post using the Share Dialog
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
.setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} else {
// Fallback. For example, publish the post using the Feed Dialog
publishFeedDialog();
}
And this is the feed dialog fallback:
private void publishFeedDialog() {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption", "Build great social apps and get more installs.");
params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
WebDialog feedDialog = (
new WebDialog.FeedDialogBuilder(getActivity(),
Session.getActiveSession(),
params)).build();
feedDialog.show();
}
Upvotes: 9
Reputation: 443
I had this exact problem, it turned out I forgot to add <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
before the </application>
tag in my AndroidManifest.xml.
Upvotes: 7