You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

2018年Android平台社交媒体登录的便捷实现方案咨询

Hey there! Let's sort out your sign-in styling and deprecated code issues right away.

First off, you're totally correct that parts of AuthUI.getInstance().createSignInIntentBuilder() are deprecated, and Google Identity Toolkit is long retired (since 2013—definitely not something to use now). The good news is there's a modern, maintained solution that will fix your button styling consistency problem in one go: using Firebase AuthUI's updated IdpConfig builders.

Here's how to implement it:

Fixing Consistent Sign-In Buttons & Replacing Deprecated Code

1. Set Up Identity Provider Configs

Instead of the old, deprecated builder approach, you'll create individual configs for Google and Facebook using their dedicated builders. This keeps your provider settings clear while letting AuthUI handle uniform styling.

Java Code Snippet:

// Configure Google Sign-In
IdpConfig googleConfig = new IdpConfig.GoogleBuilder()
        .build();

// Configure Facebook Sign-In
IdpConfig facebookConfig = new IdpConfig.FacebookBuilder()
        .build();

// Combine providers into a list
List<IdpConfig> signInProviders = Arrays.asList(googleConfig, facebookConfig);

Kotlin Code Snippet:

// Configure Google Sign-In
val googleConfig = IdpConfig.GoogleBuilder().build()

// Configure Facebook Sign-In
val facebookConfig = IdpConfig.FacebookBuilder().build()

// Combine providers into a list
val signInProviders = listOf(googleConfig, facebookConfig)

2. Build the Updated Sign-In Intent

The createSignInIntentBuilder() method is still usable—only the old constants it relied on are deprecated. Now you'll pass your configured providers to it, and AuthUI will generate a unified sign-in screen with consistent button styles:

Java Code:

Intent signInIntent = AuthUI.getInstance()
        .createSignInIntentBuilder()
        .setAvailableProviders(signInProviders)
        .setTheme(R.style.YourAppAuthTheme) // Optional: match your app's theme
        .build();

startActivityForResult(signInIntent, YOUR_SIGN_IN_REQUEST_CODE); // Use your own request code

Kotlin Code:

val signInIntent = AuthUI.getInstance()
    .createSignInIntentBuilder()
    .setAvailableProviders(signInProviders)
    .setTheme(R.style.YourAppAuthTheme) // Optional: customize to fit your app
    .build()

startActivityForResult(signInIntent, YOUR_SIGN_IN_REQUEST_CODE)

Why This Solves Your Styling Problem

By letting AuthUI handle the sign-in UI, all buttons (Google, Facebook, and any other providers you add) will automatically use matching styles that align with your app's theme. No more manually styling each button and dealing with inconsistencies!

Bonus: Customize the Theme (If Wanted)

If you want to tweak the look even more to match your app's design, create a custom theme extending your app's base theme (like Theme.MaterialComponents.Light.NoActionBar) and override attributes like:

  • colorPrimary: Sets the main button color
  • colorAccent: Adjusts accent elements
  • authButtonStyle: Lets you modify button padding, text size, and more

Just reference this custom theme in the setTheme() method when building your sign-in intent.


内容的提问来源于stack exchange,提问作者Marian Klühspies

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:00:30