Ir a la consola

FirebaseApp

public class FirebaseApp extends Object

The entry point of Firebase SDKs. It holds common configuration and state for Firebase APIs. Most applications don't need to directly interact with FirebaseApp.

For a vast majority of apps, FirebaseInitProvider will handle the initialization of Firebase for the default project that it's configured to work with, via the data contained in the app's google-services.json file. This ContentProvider is merged into the app's manifest by default when building with Gradle, and it runs automatically at app launch. No additional lines of code are needed in this case.

In the event that an app requires access to another Firebase project in addition to the default project, initializeApp(Context, FirebaseOptions, String) must be used to create that relationship programmatically. The name parameter must be unique. To connect to the resources exposed by that project, use the FirebaseApp object returned by getInstance(String), passing it the same name used with initializeApp. This object must be passed to the static accessor of the feature that provides the resource. For example, getInstance(FirebaseApp) is used to access the storage bucket provided by the additional project, whereas getInstance() is used to access the default project.

Any FirebaseApp initialization must occur only in the main process of the app. Use of Firebase in processes other than the main process is not supported and will likely cause problems related to resource contention.

Constant Summary

String DEFAULT_APP_NAME

Public Method Summary

boolean
Context
getApplicationContext()
Returns the application Context.
static List<FirebaseApp>
getApps(Context context)
Returns a mutable list of all FirebaseApps.
static FirebaseApp
getInstance(String name)
Returns the instance identified by the unique name, or throws if it does not exist.
static FirebaseApp
getInstance()
Returns the default (first initialized) instance of the FirebaseApp.
String
getName()
Returns the unique name of this app.
FirebaseOptions
getOptions()
Returns the specified FirebaseOptions.
int
static FirebaseApp
initializeApp(Context context, FirebaseOptions options)
Initializes the default FirebaseApp instance.
static FirebaseApp
initializeApp(Context context, FirebaseOptions options, String name)
A factory method to initialize a FirebaseApp.
static FirebaseApp
initializeApp(Context context)
Initializes the default FirebaseApp instance using string resource values - populated from google-services.json.
void
setAutomaticResourceManagementEnabled(boolean enabled)
If set to true it indicates that Firebase should close database connections automatically when the app is in the background.
String

Inherited Method Summary

Constants

public static final String DEFAULT_APP_NAME

Constant Value: "[DEFAULT]"

Public Methods

public boolean equals (Object o)

public Context getApplicationContext ()

Returns the application Context.

public static List<FirebaseApp> getApps (Context context)

Returns a mutable list of all FirebaseApps.

public static FirebaseApp getInstance (String name)

Returns the instance identified by the unique name, or throws if it does not exist.

Parameters
name represents the name of the FirebaseApp instance.

public static FirebaseApp getInstance ()

Returns the default (first initialized) instance of the FirebaseApp.

Throws
IllegalStateException if the default app was not initialized.

public String getName ()

Returns the unique name of this app.

public FirebaseOptions getOptions ()

Returns the specified FirebaseOptions.

public int hashCode ()

public static FirebaseApp initializeApp (Context context, FirebaseOptions options)

Initializes the default FirebaseApp instance. Same as initiali