当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseApp.getInstance方法代码示例

本文整理汇总了Java中com.google.firebase.FirebaseApp.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseApp.getInstance方法的具体用法?Java FirebaseApp.getInstance怎么用?Java FirebaseApp.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.FirebaseApp的用法示例。


在下文中一共展示了FirebaseApp.getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: firebaseApp

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Provides
@Singleton
static FirebaseApp firebaseApp(FirebaseAuthConfig config) {
  final FirebaseOptions options;
  try {
    options =
        new FirebaseOptions.Builder()
            .setCredential(
                FirebaseCredentials.fromCertificate(
                    new ByteArrayInputStream(
                        Base64.getDecoder().decode(config.getServiceAccountBase64()))))
            .setDatabaseUrl("https://" + config.getProjectId() + ".firebaseio.com")
            .build();
  } catch (IOException e) {
    throw new UncheckedIOException("Could not read certificate.", e);
  }
  FirebaseApp.initializeApp(options);
  return FirebaseApp.getInstance();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:20,代码来源:FirebaseAuthModule.java

示例2: onCreate

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // [START firebase_options]
    // Manually configure Firebase Options
    FirebaseOptions options = new FirebaseOptions.Builder()
            .setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics.
            .setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth.
            .setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB.
            .build();
    // [END firebase_options]

    // [START firebase_secondary]
    // Initialize with secondary app.
    FirebaseApp.initializeApp(this /* Context */, options, "secondary");

    // Retrieve secondary app.
    FirebaseApp secondary = FirebaseApp.getInstance("secondary");
    // Get the database for the other app.
    FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(secondary);
    // [END firebase_secondary]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:25,代码来源:MainActivity.java

示例3: onCreate

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    // Instantiate necessary Views.
    actionBarModeDisplay = (TextView) findViewById(R.id.action_bar_mode);
    googleProgressBar = (GoogleProgressBar) findViewById(R.id.google_progress);
    switchMode = (ImageButton) findViewById(R.id.changeMode);
    switchMode.setOnClickListener(this);
    countDisplay = (TextView) findViewById(R.id.countDisplay);
    countDisplay.setOnClickListener(this);
    mViewPager = (MultiViewPager) findViewById(R.id.pager);
    // Instantiate SharedPreference to get stored state.
    mPrefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

    if (mPrefs.getBoolean(VAL_FIRST_RUN, true)) { // Checks if app run for first time.
        WelcomeDialog dialog = new WelcomeDialog(this);
        dialog.show();
        current_set = new SetModel("Set 1", "cards/set1");
    } else {
        current_mode = CurrentMode.getMode(mPrefs.getString(VAL_CURRENT_MODE, CurrentMode.ENGLISH.getMode())); // Sets current mode of application
        current_set = createSet(mPrefs.getString(VAL_CURRENT_SET, CONST_DEFAULT_SET));
        actionBarModeDisplay.setText(getString(R.string.appbar_demo, current_mode.getDisplayText(), current_set.getDisplayName())); // Displays the current mode and set to user.
    }

    // Instantiate local Database
    dbHelper = new DatabaseContract.DbHelper(this);

    // Get the Firebase app and all primitives we'll use
    FirebaseApp app = FirebaseApp.getInstance();
    database = FirebaseDatabase.getInstance(app);

    // Instantiate Adaptor for ViewPager. Data added to Pager through Observer Pattern.
    loadData(current_set.getSetLocation());

    // Loading spinner data from firebase database
    loadSpinnerData();

}
 
开发者ID:riteshakya037,项目名称:Flashcards-Demo,代码行数:42,代码来源:MainActivity.java

示例4: getInstance

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
/**
 * Gets the default FirebaseDatabase instance.
 *
 * @return A FirebaseDatabase instance.
 */
public static FirebaseDatabase getInstance() {
  FirebaseApp instance = FirebaseApp.getInstance();
  if (instance == null) {
    throw new DatabaseException("You must call FirebaseApp.initialize() first.");
  }
  return getInstance(instance, instance.getOptions().getDatabaseUrl());
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:13,代码来源:FirebaseDatabase.java

示例5: FireBase

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
private FireBase() {
    app = FirebaseApp.getInstance();
    auth = FirebaseAuth.getInstance(app);

    /*
    FirebaseDatabase fdb = FirebaseDatabase.getInstance(app);
    fdb.setPersistenceEnabled(true);
    database = fdb.getReference();
    */

}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:12,代码来源:FireBase.java

示例6: AppHttpClient

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
public AppHttpClient() {
  this(FirebaseApp.getInstance());
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:4,代码来源:IntegrationTestUtils.java


注:本文中的com.google.firebase.FirebaseApp.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。