本文整理汇总了Java中com.facebook.FacebookSdk.getApplicationContext方法的典型用法代码示例。如果您正苦于以下问题:Java FacebookSdk.getApplicationContext方法的具体用法?Java FacebookSdk.getApplicationContext怎么用?Java FacebookSdk.getApplicationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.FacebookSdk
的用法示例。
在下文中一共展示了FacebookSdk.getApplicationContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllAvailableProtocolVersionsForAppInfo
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
private static TreeSet<Integer> getAllAvailableProtocolVersionsForAppInfo(
NativeAppInfo appInfo) {
TreeSet<Integer> allAvailableVersions = new TreeSet<>();
Context appContext = FacebookSdk.getApplicationContext();
ContentResolver contentResolver = appContext.getContentResolver();
String [] projection = new String[]{ PLATFORM_PROVIDER_VERSION_COLUMN };
Uri uri = buildPlatformProviderVersionURI(appInfo);
Cursor c = null;
try {
c = contentResolver.query(uri, projection, null, null, null);
if (c != null) {
while (c.moveToNext()) {
int version = c.getInt(c.getColumnIndex(PLATFORM_PROVIDER_VERSION_COLUMN));
allAvailableVersions.add(version);
}
}
} finally {
if (c != null) {
c.close();
}
}
return allAvailableVersions;
}
示例2: logShareResult
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
private static void logShareResult(String shareOutcome, String errorMessage) {
Context context = FacebookSdk.getApplicationContext();
AppEventsLogger logger = AppEventsLogger.newLogger(context);
Bundle parameters = new Bundle();
parameters.putString(
AnalyticsEvents.PARAMETER_SHARE_OUTCOME,
shareOutcome
);
if (errorMessage != null) {
parameters.putString(AnalyticsEvents.PARAMETER_SHARE_ERROR_MESSAGE, errorMessage);
}
logger.logSdkEvent(AnalyticsEvents.EVENT_SHARE_RESULT, null, parameters);
}
示例3: getLogger
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
private static synchronized LoginLogger getLogger(Context context) {
context = context != null ? context : FacebookSdk.getApplicationContext();
if (context == null) {
return null;
}
if (logger == null) {
logger = new LoginLogger(context, FacebookSdk.getApplicationId());
}
return logger;
}
示例4: fetchAllAvailableProtocolVersionsForAppInfo
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
private static TreeSet<Integer> fetchAllAvailableProtocolVersionsForAppInfo(
NativeAppInfo appInfo) {
TreeSet<Integer> allAvailableVersions = new TreeSet<>();
Context appContext = FacebookSdk.getApplicationContext();
ContentResolver contentResolver = appContext.getContentResolver();
String [] projection = new String[]{ PLATFORM_PROVIDER_VERSION_COLUMN };
Uri uri = buildPlatformProviderVersionURI(appInfo);
Cursor c = null;
try {
// First see if the base provider exists as a check for whether the native app is
// installed. We do this prior to querying, to prevent errors from being output to
// logcat saying that the provider was not found.
PackageManager pm = FacebookSdk.getApplicationContext().getPackageManager();
String contentProviderName = appInfo.getPackage() + PLATFORM_PROVIDER;
ProviderInfo pInfo = pm.resolveContentProvider(contentProviderName, 0);
if (pInfo != null) {
c = contentResolver.query(uri, projection, null, null, null);
if (c != null) {
while (c.moveToNext()) {
int version = c.getInt(c.getColumnIndex(PLATFORM_PROVIDER_VERSION_COLUMN));
allAvailableVersions.add(version);
}
}
}
return allAvailableVersions;
} finally {
if (c != null) {
c.close();
}
}
}
示例5: setupAppCallForNativeDialog
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
public static void setupAppCallForNativeDialog(
AppCall appCall,
ParameterProvider parameterProvider,
DialogFeature feature) {
Context context = FacebookSdk.getApplicationContext();
String action = feature.getAction();
int protocolVersion = getProtocolVersionForNativeDialog(feature);
if (protocolVersion == NativeProtocol.NO_PROTOCOL_AVAILABLE) {
throw new FacebookException(
"Cannot present this dialog. This likely means that the " +
"Facebook app is not installed.");
}
Bundle params;
if (NativeProtocol.isVersionCompatibleWithBucketedIntent(protocolVersion)) {
// Facebook app supports the new bucketed protocol
params = parameterProvider.getParameters();
} else {
// Facebook app only supports the old flat protocol
params = parameterProvider.getLegacyParameters();
}
if (params == null) {
params = new Bundle();
}
Intent intent = NativeProtocol.createPlatformActivityIntent(
context,
appCall.getCallId().toString(),
action,
protocolVersion,
params);
if (intent == null) {
throw new FacebookException(
"Unable to create Intent; this likely means the" +
"Facebook app is not installed.");
}
appCall.setRequestIntent(intent);
}
示例6: getQueryParamsForPlatformActivityIntentWebFallback
import com.facebook.FacebookSdk; //导入方法依赖的package包/类
public static Bundle getQueryParamsForPlatformActivityIntentWebFallback(
String callId,
int version,
Bundle methodArgs) {
Context context = FacebookSdk.getApplicationContext();
String keyHash = FacebookSdk.getApplicationSignature(context);
if (Utility.isNullOrEmpty(keyHash)) {
return null;
}
Bundle webParams = new Bundle();
webParams.putString(FALLBACK_DIALOG_PARAM_KEY_HASH, keyHash);
webParams.putString(FALLBACK_DIALOG_PARAM_APP_ID, FacebookSdk.getApplicationId());
webParams.putInt(FALLBACK_DIALOG_PARAM_VERSION, version);
webParams.putString(DIALOG_PARAM_DISPLAY, FALLBACK_DIALOG_DISPLAY_VALUE_TOUCH);
Bundle bridgeArguments = new Bundle();
bridgeArguments.putString(NativeProtocol.BRIDGE_ARG_ACTION_ID_STRING, callId);
methodArgs = (methodArgs == null) ? new Bundle() : methodArgs;
try {
JSONObject bridgeArgsJSON = BundleJSONConverter.convertToJSON(bridgeArguments);
JSONObject methodArgsJSON = BundleJSONConverter.convertToJSON(methodArgs);
if (bridgeArgsJSON == null || methodArgsJSON == null) {
return null;
}
webParams.putString(FALLBACK_DIALOG_PARAM_BRIDGE_ARGS, bridgeArgsJSON.toString());
webParams.putString(FALLBACK_DIALOG_PARAM_METHOD_ARGS, methodArgsJSON.toString());
} catch (JSONException je) {
webParams = null;
Logger.log(LoggingBehavior.DEVELOPER_ERRORS, Log.ERROR, TAG,
"Error creating Url -- " + je);
}
return webParams;
}