private void checkToolTipSettings() { switch (toolTipMode) { case AUTOMATIC: // kick off an async request final String appId = Utility.getMetadataApplicationId(getContext()); FacebookSdk.getExecutor() .execute( new Runnable() { @Override public void run() { final FetchedAppSettings settings = Utility.queryAppSettings(appId, false); getActivity() .runOnUiThread( new Runnable() { @Override public void run() { showToolTipPerSettings(settings); } }); } }); break; case DISPLAY_ALWAYS: String toolTipString = getResources().getString(R.string.com_facebook_tooltip_default); displayToolTip(toolTipString); break; case NEVER_DISPLAY: break; } }
@UnityCallable public static void Init(final String params_str) { Log.v(TAG, "Init(" + params_str + ")"); UnityParams unity_params = UnityParams.parse(params_str, "couldn't parse init params: " + params_str); final String appID; if (unity_params.hasString("appId")) { appID = unity_params.getString("appId"); } else { appID = Utility.getMetadataApplicationId(getUnityActivity()); } FacebookSdk.setApplicationId(appID); FacebookSdk.sdkInitialize( FB.getUnityActivity(), new FacebookSdk.InitializeCallback() { @Override public void onInitialized() { final UnityMessage unityMessage = new UnityMessage("OnInitComplete"); // If we have a cached access token send it back as well AccessToken token = AccessToken.getCurrentAccessToken(); if (token != null) { FBLogin.addLoginParametersToMessage(unityMessage, token, null); } else { unityMessage.put("key_hash", FB.getKeyHash()); } FB.ActivateApp(appID); unityMessage.send(); } }); }
private boolean initializeActiveSessionWithCachedToken(Context context) { if (context == null) { return false; } Session session = Session.getActiveSession(); if (session != null) { return session.isOpened(); } String applicationId = Utility.getMetadataApplicationId(context); if (applicationId == null) { return false; } return Session.openActiveSessionFromCache(context) != null; }
/** Constructor is private, newLogger() methods should be used to build an instance. */ private InsightsLogger( Context context, String clientToken, String applicationId, Session session) { Validate.notNull(context, "context"); // Always ensure the client token is present, even if not needed for this particular logging // (because at // some point it will be required). Be harsh by throwing an exception because this is all too // easy to miss // and things will work with authenticated sessions, but start failing with users that don't // have // authenticated sessions. Validate.notNullOrEmpty(clientToken, "clientToken"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } this.context = context; this.clientToken = clientToken; this.applicationId = applicationId; this.specifiedSession = session; }
public static Intent createPlatformActivityIntent( Context context, String callId, String action, int version, String applicationName, Bundle extras) { Intent intent = findActivityIntent(context, INTENT_ACTION_PLATFORM_ACTIVITY, action); if (intent == null) { return null; } String applicationId = Utility.getMetadataApplicationId(context); intent .putExtra(EXTRA_PROTOCOL_VERSION, version) .putExtra(EXTRA_PROTOCOL_ACTION, action) .putExtra(EXTRA_APPLICATION_ID, applicationId); if (isVersionCompatibleWithBucketedIntent(version)) { // This is a bucketed intent Bundle bridgeArguments = new Bundle(); bridgeArguments.putString(BRIDGE_ARG_ACTION_ID_STRING, callId); bridgeArguments.putString(BRIDGE_ARG_APP_NAME_STRING, applicationName); intent.putExtra(EXTRA_PROTOCOL_BRIDGE_ARGS, bridgeArguments); Bundle methodArguments = (extras == null) ? new Bundle() : extras; intent.putExtra(EXTRA_PROTOCOL_METHOD_ARGS, methodArguments); } else { // This is the older flat intent intent.putExtra(EXTRA_PROTOCOL_CALL_ID, callId); intent.putExtra(EXTRA_APPLICATION_NAME, applicationName); intent.putExtras(extras); } return intent; }