本文整理匯總了Java中com.facebook.FacebookSdk類的典型用法代碼示例。如果您正苦於以下問題:Java FacebookSdk類的具體用法?Java FacebookSdk怎麽用?Java FacebookSdk使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FacebookSdk類屬於com.facebook包,在下文中一共展示了FacebookSdk類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initGlobalObjects
import com.facebook.FacebookSdk; //導入依賴的package包/類
private static void initGlobalObjects(Context context, Options options) {
GlobalObjectRegistry.addObject(OpenHelperManager.getHelper(context, DatabaseHelper.class));
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.create();
GlobalObjectRegistry.addObject(gson);
ImageLoader.init(context);
EmbeddedSocialServiceProvider serviceProvider = new EmbeddedSocialServiceProvider(context);
GlobalObjectRegistry.addObject(EmbeddedSocialServiceProvider.class, serviceProvider);
GlobalObjectRegistry.addObject(new Preferences(context));
GlobalObjectRegistry.addObject(new RequestInfoProvider(context));
GlobalObjectRegistry.addObject(new UserAccount(context));
GlobalObjectRegistry.addObject(new NotificationController(context));
NetworkAvailability networkAccessibility = new NetworkAvailability();
networkAccessibility.startMonitoring(context);
GlobalObjectRegistry.addObject(networkAccessibility);
FacebookSdk.sdkInitialize(context);
FacebookSdk.setApplicationId(options.getFacebookApplicationId());
}
示例2: initialize
import com.facebook.FacebookSdk; //導入依賴的package包/類
private void initialize()
throws FileNotFoundException {
ParcelFileDescriptor fileDescriptor = null;
try {
if (Utility.isFileUri(videoUri)) {
fileDescriptor = ParcelFileDescriptor.open(
new File(videoUri.getPath()),
ParcelFileDescriptor.MODE_READ_ONLY);
videoSize = fileDescriptor.getStatSize();
videoStream = new ParcelFileDescriptor.AutoCloseInputStream(fileDescriptor);
} else if (Utility.isContentUri(videoUri)) {
videoSize = Utility.getContentSize(videoUri);
videoStream = FacebookSdk
.getApplicationContext()
.getContentResolver()
.openInputStream(videoUri);
} else {
throw new FacebookException("Uri must be a content:// or file:// uri");
}
} catch (FileNotFoundException e) {
Utility.closeQuietly(videoStream);
throw e;
}
}
示例3: shareToMessenger20150314
import com.facebook.FacebookSdk; //導入依賴的package包/類
private static void shareToMessenger20150314(
Activity activity,
int requestCode,
ShareToMessengerParams shareToMessengerParams) {
try {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setPackage(PACKAGE_NAME);
shareIntent.putExtra(Intent.EXTRA_STREAM, shareToMessengerParams.uri);
shareIntent.setType(shareToMessengerParams.mimeType);
String appId = FacebookSdk.getApplicationId();
if (appId != null) {
shareIntent.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION_20150314);
shareIntent.putExtra(EXTRA_APP_ID, appId);
shareIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData);
shareIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri);
}
activity.startActivityForResult(shareIntent, requestCode);
} catch (ActivityNotFoundException e) {
Intent openMessenger = activity.getPackageManager().getLaunchIntentForPackage(PACKAGE_NAME);
activity.startActivity(openMessenger);
}
}
示例4: finishShareToMessenger
import com.facebook.FacebookSdk; //導入依賴的package包/類
/**
* Finishes the activity and returns the media item the user picked to Messenger.
*
* @param activity the activity that received the original intent from Messenger
* @param shareToMessengerParams parameters for what to share
*/
public static void finishShareToMessenger(
Activity activity,
ShareToMessengerParams shareToMessengerParams) {
Intent originalIntent = activity.getIntent();
Set<String> categories = originalIntent.getCategories();
if (categories == null) {
// This shouldn't happen.
activity.setResult(Activity.RESULT_CANCELED, null);
activity.finish();
return;
}
if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
Bundle appLinkExtras = AppLinks.getAppLinkExtras(originalIntent);
Intent resultIntent = new Intent();
if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
resultIntent.putExtra(EXTRA_PROTOCOL_VERSION, MessengerUtils.PROTOCOL_VERSION_20150314);
String threadToken = appLinkExtras.getString(MessengerUtils.EXTRA_THREAD_TOKEN_KEY);
resultIntent.putExtra(EXTRA_THREAD_TOKEN_KEY, threadToken);
} else {
throw new RuntimeException(); // Can't happen.
}
resultIntent.setDataAndType(shareToMessengerParams.uri, shareToMessengerParams.mimeType);
resultIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
resultIntent.putExtra(EXTRA_APP_ID, FacebookSdk.getApplicationId());
resultIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData);
resultIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri);
activity.setResult(Activity.RESULT_OK, resultIntent);
activity.finish();
} else {
// This shouldn't happen.
activity.setResult(Activity.RESULT_CANCELED, null);
activity.finish();
}
}
示例5: fetchDeferredAppLinkData
import com.facebook.FacebookSdk; //導入依賴的package包/類
/**
* Asynchronously fetches app link information that might have been stored for use after
* installation of the app
*
* @param context The context
* @param applicationId Facebook application Id. If null, it is taken from the manifest
* @param completionHandler CompletionHandler to be notified with the AppLinkData object or null
* if none is available. Must not be null.
*/
public static void fetchDeferredAppLinkData(
Context context,
String applicationId,
final CompletionHandler completionHandler) {
Validate.notNull(context, "context");
Validate.notNull(completionHandler, "completionHandler");
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
Validate.notNull(applicationId, "applicationId");
final Context applicationContext = context.getApplicationContext();
final String applicationIdCopy = applicationId;
FacebookSdk.getExecutor().execute(new Runnable() {
@Override
public void run() {
fetchDeferredAppLinkFromServer(
applicationContext, applicationIdCopy, completionHandler);
}
});
}
示例6: setupAppCallForErrorResult
import com.facebook.FacebookSdk; //導入依賴的package包/類
public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) {
if (exception == null) {
return;
}
Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
Intent errorResultIntent = new Intent();
errorResultIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION);
NativeProtocol.setupProtocolRequestIntent(
errorResultIntent,
appCall.getCallId().toString(),
null,
NativeProtocol.getLatestKnownVersion(),
NativeProtocol.createBundleForException(exception));
appCall.setRequestIntent(errorResultIntent);
}
示例7: setupAppCallForWebDialog
import com.facebook.FacebookSdk; //導入依賴的package包/類
public static void setupAppCallForWebDialog(
AppCall appCall,
String actionName,
Bundle parameters) {
Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());
Bundle intentParameters = new Bundle();
intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION, actionName);
intentParameters.putBundle(NativeProtocol.WEB_DIALOG_PARAMS, parameters);
Intent webDialogIntent = new Intent();
NativeProtocol.setupProtocolRequestIntent(
webDialogIntent,
appCall.getCallId().toString(),
actionName,
NativeProtocol.getLatestKnownVersion(),
intentParameters);
webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
webDialogIntent.setAction(FacebookDialogFragment.TAG);
appCall.setRequestIntent(webDialogIntent);
}
示例8: processAttachmentFile
import com.facebook.FacebookSdk; //導入依賴的package包/類
private static void processAttachmentFile(
Uri imageUri,
boolean isContentUri,
File outputFile) throws IOException {
FileOutputStream outputStream = new FileOutputStream(outputFile);
try {
InputStream inputStream = null;
if (!isContentUri) {
inputStream = new FileInputStream(imageUri.getPath());
} else {
inputStream = FacebookSdk
.getApplicationContext()
.getContentResolver()
.openInputStream(imageUri);
}
Utility.copyAndCloseInputStream(inputStream, outputStream);
} finally {
Utility.closeQuietly(outputStream);
}
}
示例9: getContentSize
import com.facebook.FacebookSdk; //導入依賴的package包/類
public static long getContentSize(final Uri contentUri) {
Cursor cursor = null;
try {
cursor = FacebookSdk
.getApplicationContext()
.getContentResolver()
.query(contentUri, null, null, null, null);
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
cursor.moveToFirst();
return cursor.getLong(sizeIndex);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例10: updateAllAvailableProtocolVersionsAsync
import com.facebook.FacebookSdk; //導入依賴的package包/類
public static void updateAllAvailableProtocolVersionsAsync() {
if (!protocolVersionsAsyncUpdating.compareAndSet(false, true)) {
return;
}
FacebookSdk.getExecutor().execute(new Runnable() {
@Override
public void run() {
try {
for (NativeAppInfo appInfo : facebookAppInfoList) {
appInfo.fetchAvailableVersions(true);
}
} finally {
protocolVersionsAsyncUpdating.set(false);
}
}
});
}
示例11: showImpl
import com.facebook.FacebookSdk; //導入依賴的package包/類
protected void showImpl(final CONTENT content, final Object mode) {
AppCall appCall = createAppCallForMode(content, mode);
if (appCall != null) {
if (fragment != null) {
DialogPresenter.present(appCall, fragment);
} else {
DialogPresenter.present(appCall, activity);
}
} else {
// If we got a null appCall, then the derived dialog code is doing something wrong
String errorMessage = "No code path should ever result in a null appCall";
Log.e(TAG, errorMessage);
if (FacebookSdk.isDebugEnabled()) {
throw new IllegalStateException(errorMessage);
}
}
}
示例12: onCreate
import com.facebook.FacebookSdk; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!FacebookSdk.isInitialized()) {
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(getActivity().getApplication());
}
// Initialize Firebase Auth
fireBaseAuth = FirebaseAuth.getInstance();
fireBaseAuth.signOut();
facebookCallbackManager = CallbackManager.Factory.create();
registerFirebase();
registerFacebookCallback();
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
}
示例13: fetchAllAvailableProtocolVersionsForAppInfo
import com.facebook.FacebookSdk; //導入依賴的package包/類
private static TreeSet<Integer> fetchAllAvailableProtocolVersionsForAppInfo(NativeAppInfo appInfo) {
TreeSet<Integer> allAvailableVersions = new TreeSet();
ContentResolver contentResolver = FacebookSdk.getApplicationContext().getContentResolver();
String[] projection = new String[]{"version"};
Uri uri = buildPlatformProviderVersionURI(appInfo);
Cursor c = null;
try {
if (FacebookSdk.getApplicationContext().getPackageManager().resolveContentProvider(appInfo.getPackage() + PLATFORM_PROVIDER, 0) != null) {
c = contentResolver.query(uri, projection, null, null, null);
if (c != null) {
while (c.moveToNext()) {
allAvailableVersions.add(Integer.valueOf(c.getInt(c.getColumnIndex("version"))));
}
}
}
if (c != null) {
c.close();
}
return allAvailableVersions;
} catch (Throwable th) {
if (c != null) {
c.close();
}
}
}
示例14: onCreate
import com.facebook.FacebookSdk; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
if(AppController.USER_ID != null && AppController.USER_TOKEN != null) {
new CountDownTimer(1000, 100) {
public void onTick(long millisUntilFinished) { }
public void onFinish() {
goActivityMain();
}
}.start();
} else {
changeToLoginView();
}
pref = getSharedPreferences(CONST.PREF_NAME, MODE_PRIVATE);
editor = pref.edit();
}
示例15: initFBSdk
import com.facebook.FacebookSdk; //導入依賴的package包/類
private void initFBSdk() {
if (!FacebookSdk.isInitialized()) {
FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
}
callbackManager = CallbackManager.Factory.create();
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
if (eventHandler != null) {
if (currentProfile != null)
eventHandler.onFacebookLoggedIn();
}
}
};
}