java.lang.Object | |
↳ | com.google.firebase.FirebaseApp |
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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_APP_NAME |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the application
Context . | |||||||||||
Returns a mutable list of all FirebaseApps.
| |||||||||||
Returns the instance identified by the unique name, or throws if it does not exist.
| |||||||||||
Returns the default (first initialized) instance of the
FirebaseApp . | |||||||||||
Returns the unique name of this app.
| |||||||||||
Returns the specified
FirebaseOptions . | |||||||||||
Initializes the default
FirebaseApp instance. | |||||||||||
A factory method to intialize a
FirebaseApp . | |||||||||||
Initializes the default FirebaseApp instance using string resource values -
populated from google-services.json.
| |||||||||||
If set to true it indicates that Firebase should close database connections automatically
when the app is in the background.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Parameters | |
---|---|
o |
Object
|
Returns | |
---|---|
boolean |
Returns the instance identified by the unique name, or throws if it does not exist.
Parameters | |
---|---|
name |
String :
represents the name of the FirebaseApp instance. |
Returns | |
---|---|
FirebaseApp |
Throws | |
---|---|
IllegalStateException |
if the FirebaseApp was not initialized, either via
initializeApp(Context, FirebaseOptions, String) .
|
Returns the default (first initialized) instance of the FirebaseApp
.
Returns | |
---|---|
FirebaseApp |
Throws | |
---|---|
IllegalStateException |
if the default app was not initialized. |
Returns the unique name of this app.
Returns | |
---|---|
String |
Returns | |
---|---|
int |
Initializes the default FirebaseApp
instance. Same as
initializeApp(Context, FirebaseOptions, String)
, but it uses DEFAULT_APP_NAME
as name.
It's only required to call this to initialize Firebase if it's not possible
to do so automatically in FirebaseInitProvider
.
Automatic initialization that way is the expected situation.
Parameters | |
---|---|
context |
Context
|
options |
FirebaseOptions
|
Returns | |
---|---|
FirebaseApp |
A factory method to intialize a FirebaseApp
.
Parameters | |
---|---|
context |
Context :
represents the Context |
options |
FirebaseOptions :
represents the global FirebaseOptions |
name |
String :
unique name for the app. It is an error to initialize an app with an
already existing name. Starting and ending whitespace characters in the
name are ignored (trimmed). |
Returns | |
---|---|
FirebaseApp |
an instance of FirebaseApp
|
Throws | |
---|---|
IllegalStateException |
if an app with the same name has already been initialized. |
Initializes the default FirebaseApp instance using string resource values - populated from google-services.json. It also initializes Firebase Analytics for the current process.
This method is called at app startup time by
FirebaseInitProvider
. Call this method before any
Firebase APIs in components outside the main process.
The FirebaseOptions
values used by the default app instance are read
from string resources.
Parameters | |
---|---|
context |
Context
|
Returns | |
---|---|
FirebaseApp |
the default FirebaseApp, if either it has been initialized previously, or Firebase API keys are present in string resources. Returns null otherwise. |
If set to true it indicates that Firebase should close database connections automatically when the app is in the background. Disabled by default.
Parameters | |
---|---|
enabled |
boolean
|
Returns | |
---|---|
String |