本文整理匯總了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;
}