当前位置: 首页>>代码示例>>Java>>正文


Java FacebookSdk类代码示例

本文整理汇总了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());
}
 
开发者ID:Microsoft,项目名称:EmbeddedSocial-Android-SDK,代码行数:20,代码来源:EmbeddedSocial.java

示例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;
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:26,代码来源:VideoUploader.java

示例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);
  }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:25,代码来源:MessengerUtils.java

示例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();
  }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:43,代码来源:MessengerUtils.java

示例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);
        }
    });
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:33,代码来源:AppLinkData.java

示例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);
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:20,代码来源:DialogPresenter.java

示例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);
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:24,代码来源:DialogPresenter.java

示例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);
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:22,代码来源:NativeAppCallAttachmentStore.java

示例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();
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:18,代码来源:Utility.java

示例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);
            }
        }
    });
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:19,代码来源:NativeProtocol.java

示例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);
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:18,代码来源:FacebookDialogBase.java

示例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"));
}
 
开发者ID:Pavou,项目名称:Stalker,代码行数:17,代码来源:AuthenticateFragment.java

示例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();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:NativeProtocol.java

示例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();
}
 
开发者ID:lecrec,项目名称:lecrec-android,代码行数:21,代码来源:ActivityLaunchScreen.java

示例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();
            }
        }
    };
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:18,代码来源:FacebookShield.java


注:本文中的com.facebook.FacebookSdk类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。