Java 类com.facebook.FacebookActivity 实例源码

项目:kognitivo    文件:DialogPresenter.java   
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);
}
项目:kognitivo    文件:DialogPresenter.java   
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);
}
项目:kognitivo    文件:Validate.java   
public static void hasFacebookActivity(Context context, boolean shouldThrow) {
    Validate.notNull(context, "context");
    PackageManager pm = context.getPackageManager();
    ActivityInfo activityInfo = null;
    if (pm != null) {
        ComponentName componentName =
                new ComponentName(context, FacebookActivity.class);
        try {
            activityInfo = pm.getActivityInfo(componentName, PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
    if (activityInfo == null) {
        if (shouldThrow) {
            throw new IllegalStateException(FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        } else {
            Log.w(TAG, FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        }
    }
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) {
    if (exception == null) {
        return;
    }

    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);
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForWebDialog(
        AppCall appCall,
        String actionName,
        Bundle parameters) {
    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);
}
项目:SocioBlood    文件:DialogPresenter.java   
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);
}
项目:SocioBlood    文件:DialogPresenter.java   
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);
}
项目:SocioBlood    文件:Validate.java   
public static void hasFacebookActivity(Context context, boolean shouldThrow) {
    Validate.notNull(context, "context");
    PackageManager pm = context.getPackageManager();
    ActivityInfo activityInfo = null;
    if (pm != null) {
        ComponentName componentName =
                new ComponentName(context, FacebookActivity.class);
        try {
            activityInfo = pm.getActivityInfo(componentName, PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
    if (activityInfo == null) {
        if (shouldThrow) {
            throw new IllegalStateException(FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        } else {
            Log.w(TAG, FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        }
    }
}
项目:kognitivo    文件:LoginManager.java   
private Intent getFacebookActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let FacebookActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = new Bundle();
    extras.putParcelable(LoginFragment.EXTRA_REQUEST, request);
    intent.putExtras(extras);

    return intent;
}
项目:androidadvanced    文件:RecipeListActivityTest.java   
@Test
public void testRecyclerViewFBShareClicked_ShouldStartFBActivity() throws Exception {
    int positionToClick = 0;
    setUpShadowAdapter(positionToClick);

    shadowAdapter.itemVisible(positionToClick);
    shadowAdapter.performItemClickOverViewInHolder(positionToClick, R.id.fbShare);

    Intent intent = shadowActivity.peekNextStartedActivity();
    assertEquals(new ComponentName(RuntimeEnvironment.application, FacebookActivity.class), intent.getComponent());
}
项目:androidadvanced    文件:RecipeListActivityTest.java   
@Test
public void testRecyclerViewFBSendClicked_ShouldStartFBActivity() throws Exception {
    int positionToClick = 0;
    setUpShadowAdapter(positionToClick);

    shadowAdapter.itemVisible(positionToClick);
    shadowAdapter.performItemClickOverViewInHolder(positionToClick, R.id.fbSend);

    Intent intent = shadowActivity.peekNextStartedActivity();
    assertEquals(new ComponentName(RuntimeEnvironment.application, FacebookActivity.class), intent.getComponent());
}
项目:Move-Alarm_ORCA    文件:LoginManager.java   
private Intent getLoginActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let LoginActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = LoginFragment.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}
项目:SocioBlood    文件:LoginManager.java   
private Intent getFacebookActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let FacebookActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = LoginFragment.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}
项目:kognitivo    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,
        Bundle parameters,
        DialogFeature feature) {
    Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
    Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());

    String featureName = feature.name();
    Uri fallbackUrl = getDialogWebFallbackUri(feature);
    if (fallbackUrl == null) {
        throw new FacebookException(
                "Unable to fetch the Url for the DialogFeature : '" + featureName + "'");
    }

    // Since we're talking to the server here, let's use the latest version we know about.
    // We know we are going to be communicating over a bucketed protocol.
    int protocolVersion = NativeProtocol.getLatestKnownVersion();
    Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback(
            appCall.getCallId().toString(),
            protocolVersion,
            parameters);
    if (webParams == null) {
        throw new FacebookException("Unable to fetch the app's key-hash");
    }

    // Now form the Uri
    if (fallbackUrl.isRelative()) {
        fallbackUrl = Utility.buildUri(
                ServerProtocol.getDialogAuthority(),
                fallbackUrl.toString(),
                webParams);
    } else {
        fallbackUrl = Utility.buildUri(
                fallbackUrl.getAuthority(),
                fallbackUrl.getPath(),
                webParams);
    }

    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_URL, fallbackUrl.toString());
    intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true);

    Intent webDialogIntent = new Intent();
    NativeProtocol.setupProtocolRequestIntent(
            webDialogIntent,
            appCall.getCallId().toString(),
            feature.getAction(),
            NativeProtocol.getLatestKnownVersion(),
            intentParameters);
    webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,
        Bundle parameters,
        DialogFeature feature) {
    String featureName = feature.name();
    Uri fallbackUrl = getDialogWebFallbackUri(feature);
    if (fallbackUrl == null) {
        throw new FacebookException(
                "Unable to fetch the Url for the DialogFeature : '" + featureName + "'");
    }

    // Since we're talking to the server here, let's use the latest version we know about.
    // We know we are going to be communicating over a bucketed protocol.
    int protocolVersion = NativeProtocol.getLatestKnownVersion();
    Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback(
            appCall.getCallId().toString(),
            protocolVersion,
            parameters);
    if (webParams == null) {
        throw new FacebookException("Unable to fetch the app's key-hash");
    }

    // Now form the Uri
    if (fallbackUrl.isRelative()) {
        fallbackUrl = Utility.buildUri(
                ServerProtocol.getDialogAuthority(),
                fallbackUrl.toString(),
                webParams);
    } else {
        fallbackUrl = Utility.buildUri(
                fallbackUrl.getAuthority(),
                fallbackUrl.getPath(),
                webParams);
    }

    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_URL, fallbackUrl.toString());
    intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true);

    Intent webDialogIntent = new Intent();
    NativeProtocol.setupProtocolRequestIntent(
            webDialogIntent,
            appCall.getCallId().toString(),
            feature.getAction(),
            NativeProtocol.getLatestKnownVersion(),
            intentParameters);
    webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:SocioBlood    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,
        Bundle parameters,
        DialogFeature feature) {
    Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
    Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());

    String featureName = feature.name();
    Uri fallbackUrl = getDialogWebFallbackUri(feature);
    if (fallbackUrl == null) {
        throw new FacebookException(
                "Unable to fetch the Url for the DialogFeature : '" + featureName + "'");
    }

    // Since we're talking to the server here, let's use the latest version we know about.
    // We know we are going to be communicating over a bucketed protocol.
    int protocolVersion = NativeProtocol.getLatestKnownVersion();
    Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback(
            appCall.getCallId().toString(),
            protocolVersion,
            parameters);
    if (webParams == null) {
        throw new FacebookException("Unable to fetch the app's key-hash");
    }

    // Now form the Uri
    if (fallbackUrl.isRelative()) {
        fallbackUrl = Utility.buildUri(
                ServerProtocol.getDialogAuthority(),
                fallbackUrl.toString(),
                webParams);
    } else {
        fallbackUrl = Utility.buildUri(
                fallbackUrl.getAuthority(),
                fallbackUrl.getPath(),
                webParams);
    }

    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_URL, fallbackUrl.toString());
    intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true);

    Intent webDialogIntent = new Intent();
    NativeProtocol.setupProtocolRequestIntent(
            webDialogIntent,
            appCall.getCallId().toString(),
            feature.getAction(),
            NativeProtocol.getLatestKnownVersion(),
            intentParameters);
    webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}