本文整理汇总了Java中com.facebook.widget.FacebookDialog类的典型用法代码示例。如果您正苦于以下问题:Java FacebookDialog类的具体用法?Java FacebookDialog怎么用?Java FacebookDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FacebookDialog类属于com.facebook.widget包,在下文中一共展示了FacebookDialog类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancelPendingAppCall
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
if (facebookDialogCallback != null) {
Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();
Intent cancelIntent = new Intent();
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);
FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
}
pendingFacebookDialogCall = null;
}
示例2: shareOnFacebook
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private void shareOnFacebook(String link, String picUrl) {
// Publish the post using the Share Dialog
FacebookDialog.ShareDialogBuilder shareDialogBuilder = new FacebookDialog.ShareDialogBuilder(this)
.setCaption(getString(R.string.app_name))
.setName(getString(R.string.app_name))
.setDescription(mFortune.toString())
.setLink(link)
.setPicture(picUrl);
if (shareDialogBuilder.canPresent()) {
uiHelper.trackPendingDialogCall(shareDialogBuilder.build().present());
} else {
Toast.makeText(this, getString(R.string.facebook_not_installed_or_outdated), Toast.LENGTH_SHORT).show();
openGooglePlayIfPossible(getString(R.string.facebook_main_package));
}
}
示例3: shareOnFacebookMessenger
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private void shareOnFacebookMessenger(String link, String picUrl) {
// Check if the Facebook app is installed and we can present the share dialog
FacebookDialog.MessageDialogBuilder messageDialogBuilder = new FacebookDialog.MessageDialogBuilder(this)
.setCaption(getString(R.string.app_name))
.setName(getString(R.string.app_name))
.setLink(link)
.setPicture(picUrl)
.setDescription(mFortune.toString());
// If the Facebook app is installed and we can present the share dialog
if (messageDialogBuilder.canPresent()) {
uiHelper.trackPendingDialogCall(messageDialogBuilder.build().present());
} else {
Toast.makeText(this, getString(R.string.facebook_messenger_not_installed_or_outdated), Toast.LENGTH_SHORT).show();
openGooglePlayIfPossible(getString(R.string.facebook_messenger_main_package));
}
}
示例4: onActivityResult
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private boolean onActivityResult(int requestCode, int resultCode, Intent data, UUID callId) {
if (pendingCallId == null || !pendingCallId.equals(callId)) {
return false;
}
// See if we were waiting for a dialog completion
FacebookDialog.PendingCall pendingCall = PendingCallStore.getInstance().getPendingCallById(pendingCallId);
if (pendingCall == null) {
return false;
}
// Look for results
FacebookDialog.handleActivityResult(
context,
pendingCall,
requestCode,
data,
getFacebookDialogCallback(pendingCallAnalyticsBundle));
// The handlers from above will run synchronously. So by the time we get here, it should be safe to
// stop tracking this call and also serialize the controller to disk
stopTrackingPendingCall();
return true;
}
示例5: inviteFriends
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
public void inviteFriends(View view) {
// If the Facebook Messenger app is installed and we can present
// the share dialog
if (builder.canPresent()) {
FacebookDialog dialog = builder.build();
dialog.present();
} else {
// show Sharing options
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent
.putExtra(
Intent.EXTRA_TEXT,
"Hi, install this app to video call me for free : https://play.google.com/store/apps/details?id=com.threebytes.callservicesamplefb");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Video Call Me For FREE");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Invite a friend"));
}
}
示例6: onActivityResult
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private boolean onActivityResult(int requestCode, int resultCode, Intent data, UUID callId) {
if (pendingCallId == null || !pendingCallId.equals(callId)) {
return false;
}
// See if we were waiting for a dialog completion
FacebookDialog.PendingCall pendingCall = PendingCallStore.getInstance().getPendingCallById(pendingCallId);
if (pendingCall == null) {
return false;
}
// Look for results
FacebookDialog.handleActivityResult(
applicationContext,
pendingCall,
requestCode,
data,
getFacebookDialogCallback(pendingCallAnalyticsBundle));
// The handlers from above will run synchronously. So by the time we get here, it should be safe to
// stop tracking this call and also serialize the controller to disk
stopTrackingPendingCall();
return true;
}
示例7: shareToFB
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private void shareToFB(Context context, String badgeName) {
String description = context.getResources().getText(context.getResources()
.getIdentifier(badgeName + "FB", "string", context.getPackageName())).toString();
String imgURL = context.getResources().getText(context.getResources()
.getIdentifier(badgeName + "imgURL", "string", context.getPackageName())).toString();
if (FacebookDialog.canPresentOpenGraphActionDialog(context.getApplicationContext(),
FacebookDialog.OpenGraphActionDialogFeature.OG_ACTION_DIALOG)) {
OpenGraphObject badge = OpenGraphObject.Factory.createForPost
(OpenGraphObject.class, "exercisemeapp:badge", "I earned a new badge!",
imgURL, null, description);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("badge", badge);
action.setType("exercisemeapp:earn");
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "badge")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} else {
Toast.makeText(getActivity(), "Facebook not available", Toast.LENGTH_SHORT).show();
}
}
示例8: onActivityResult
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
/**
* To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
* call are expected.
*
* @param requestCode the request code
* @param resultCode the result code
* @param data the result data
* @param dialogCallback the callback for handling FacebookDialog results, can be null
*/
public void onActivityResult(int requestCode, int resultCode, Intent data,
FacebookDialog.Callback facebookDialogCallback) {
Session session = Session.getActiveSession();
if (session != null) {
session.onActivityResult(activity, requestCode, resultCode, data);
}
handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
示例9: trackPendingDialogCall
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
/**
* Register that we are expecting results from a call to the Facebook application (e.g., from a native
* dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
* and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
* at a time; attempting to track another one will cancel the first one.
* @param appCall an PendingCall object containing the call ID
*/
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
if (pendingFacebookDialogCall != null) {
// If one is already pending, cancel it; we don't allow multiple pending calls.
Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
cancelPendingAppCall(null);
}
pendingFacebookDialogCall = pendingCall;
}
示例10: handleFacebookDialogActivityResult
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
FacebookDialog.Callback facebookDialogCallback) {
if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
return false;
}
if (data == null) {
// We understand the request code, but have no Intent. This can happen if the called Activity crashes
// before it can be started; we treat this as a cancellation because we have no other information.
cancelPendingAppCall(facebookDialogCallback);
return true;
}
String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
UUID callId = null;
if (callIdString != null) {
try {
callId = UUID.fromString(callIdString);
} catch (IllegalArgumentException exception) {
}
}
// Was this result for the call we are waiting on?
if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
// Yes, we can handle it normally.
FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
facebookDialogCallback);
} else {
// No, send a cancellation error to the pending call and ignore the result, because we
// don't know what to do with it.
cancelPendingAppCall(facebookDialogCallback);
}
pendingFacebookDialogCall = null;
return true;
}
示例11: share
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
@Override
public void share(String tag)
{
switch(tag) {
case "facebook":
ArrayList<Bitmap> pic = new ArrayList<>();
pic.add(screenShot());
if (FacebookDialog.canPresentShareDialog (getApplicationContext(),
FacebookDialog.ShareDialogFeature.PHOTOS)) {
// Publish the post using the Photo Share Dialog
FacebookDialog shareDialog = new FacebookDialog.PhotoShareDialogBuilder(this)
.addPhotos(pic)
.setApplicationName("Chatois")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} else {
// The user doesn't have the Facebook for Android app installed.
// You may be able to use a fallback.
}
// FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
// .setLink("https://play.google.com/store/apps/details?id=com.chatois.app")
// .setDescription("Description")
// .setName("name")
// .setApplicationName("Chatois!")
// .setCaption("Caption")
// .build();
// uiHelper.trackPendingDialogCall(shareDialog.present());
break;
case "whatsapp":
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Can you help me guess this word?");
sendIntent.putExtra(Intent.EXTRA_STREAM, getImageUri(screenShot()));
sendIntent.setType("image/*");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
break;
}
}
示例12: share
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
public Observable<Bundle> share(Photo photo) {
Log.d("RetroFacebook", "share");
//if (FacebookDialog.canPresentShareDialog(activity, ShareDialogFeature.PHOTOS)) {
//}
FacebookDialog shareDialog = new FacebookDialog.PhotoShareDialogBuilder(activity)
.addPhotos(Arrays.asList(photo.pictureBitmap()))
//.setPlace(photo.placeId())
.build();
return trackPendingDialogCall(shareDialog);
}
示例13: trackPendingDialogCall
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
private Observable<Bundle> trackPendingDialogCall(FacebookDialog shareDialog) {
Log.d("RetroFacebook", "trackPendingDialogCall");
//Subject<Bundle, Bundle> sub = BehaviorSubject.create();
//dialogSubject = BehaviorSubject.create();
PendingCall pendingCall = shareDialog.present();
//dialogSubs.put(pendingCall.getCallId(), sub);
uiLifecycleHelper.trackPendingDialogCall(pendingCall);
//return sub.asObservable();
return dialogSubject.asObservable().take(1);
}
示例14: shareOnFacebook
import com.facebook.widget.FacebookDialog; //导入依赖的package包/类
protected void shareOnFacebook(Marker marker){
Log.d("App name: ",getString(R.string.app_name));
if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
// Publish the post using the Share Dialog
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(MainMapActivity.this)
.setLink("http://maps.google.com/maps?z=15&t=m&q=loc:" + marker.getPosition().latitude + "+" + marker.getPosition().longitude)
.setName(marker.getTitle())
.setCaption("via Geopin App")
.setDescription(marker.getSnippet())
.setApplicationName(getString(R.string.app_name))
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
}