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


Java FirebaseDatabase.getInstance方法代码示例

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


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

示例1: onCreateView

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        if (mColumnCount <= 1) {
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
        } else {
            recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
        }
        adapter = new JournalAdapter(allTrips, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:26,代码来源:JournalFragment.java

示例2: testDatabaseAuthVariablesAuthorization

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Test
public void testDatabaseAuthVariablesAuthorization() throws InterruptedException {
  Map<String, Object> authVariableOverrides = ImmutableMap.<String, Object>of(
      "uid", "test",
      "custom", "secret"
  );
  FirebaseOptions options =
      new FirebaseOptions.Builder(masterApp.getOptions())
          .setDatabaseAuthVariableOverride(authVariableOverrides)
          .build();
  FirebaseApp testUidApp = FirebaseApp.initializeApp(options, "testGetAppWithUid");
  FirebaseDatabase masterDb = FirebaseDatabase.getInstance(masterApp);
  FirebaseDatabase testAuthOverridesDb = FirebaseDatabase.getInstance(testUidApp);

  assertWriteSucceeds(masterDb.getReference());

  // "test" UID can only read/write to /test-uid-only and /test-custom-field-only locations.
  assertWriteFails(testAuthOverridesDb.getReference());
  assertWriteSucceeds(testAuthOverridesDb.getReference("test-uid-only"));
  assertReadSucceeds(testAuthOverridesDb.getReference("test-uid-only"));
  assertWriteSucceeds(testAuthOverridesDb.getReference("test-custom-field-only"));
  assertReadSucceeds(testAuthOverridesDb.getReference("test-custom-field-only"));
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:24,代码来源:FirebaseDatabaseAuthTestIT.java

示例3: setContent

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
private void setContent() {
    setContentView(R.layout.activity_login);
    screen = (RelativeLayout)findViewById(R.id.rl);
    ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
    TransitionDrawable trans = new TransitionDrawable(color);
    screen.setBackgroundDrawable(trans);
    trans.startTransition(1800);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
            .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mAuth = FirebaseAuth.getInstance();

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    root= database.getReference("room_names");
    loadRooms();
    new CountDownTimer(2500, 1000) {
        public void onTick(long millisUntilDone) { }
        public void onFinish() {
            currentUser = mAuth.getCurrentUser();
            updateUI(currentUser);
        }
    }.start();
}
 
开发者ID:YoungPeacock,项目名称:FantaF1,代码行数:26,代码来源:LoginActivity.java

示例4: onCreate

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_home);
    setContentView(R.layout.fragment_feed);
    Log.d(TAG, "onCreate: starting");

    setupBottomNavigationBar();
    mAuth = FirebaseAuth.getInstance();
    mDatabase = FirebaseDatabase.getInstance();

    mFeed = findViewById(R.id.myFeed);
    Log.d(TAG, mFeed.toString());
    listAdapter = new MainFeedListAdapter(HomeActivity.this, R.layout.layout_feed_list_item, posts);
    mFeed.setAdapter(listAdapter);
    downloadMyFeed();
}
 
开发者ID:sindhu732,项目名称:instagram_clone,代码行数:18,代码来源:HomeActivity.java

示例5: provideFirebaseDatabase

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Singleton
@Provides
FirebaseDatabase provideFirebaseDatabase() {
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    firebaseDatabase.setPersistenceEnabled(true); //for offline access
    return firebaseDatabase;
}
 
开发者ID:wahibhaq,项目名称:urdu-font-comparator-app,代码行数:8,代码来源:FirebaseModule.java

示例6: onCreateView

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_detail_product, container, false);

    android_id = Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.ANDROID_ID);

    FirebaseApp.initializeApp(getActivity());
    firebaseDatabase = FirebaseDatabase.getInstance();
    databaseReference = firebaseDatabase.getReference("basket").child(android_id);

    btnAddBasket = (FlatButton) view.findViewById(R.id.btnAddBasket);
    btnAddBasket.setOnClickListener(this);
    progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage("Ürün Yükleniyor..");
    progressDialog.show();
    progressDialog.hide();

    //OnSuucese kaydet

    sliderLayout = (SliderLayout) view.findViewById(R.id.slider);
    tvPrice = (TextView) view.findViewById(R.id.tvPrice);
    etPiece = (EditText) view.findViewById(R.id.etPiece);
    etPiece.addTextChangedListener(this);

    imageList = new ArrayList<>();
    productIdExstra = getArguments().getInt("id");

    urlDetail+=productIdExstra;

    Request request = new Request(getActivity(), urlDetail, com.android.volley.Request.Method.GET);
    request.requestVolley(this);

    return view;
}
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:36,代码来源:DetailPrıductFragment.java

示例7: useAppContext

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Test
@Ignore
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.quartzodev.buddybook", appContext.getPackageName());

    FirebaseDatabase.getInstance();

}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:12,代码来源:ExampleInstrumentedTest.java

示例8: save

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@OnClick(R.id.save_button)
public void save() {
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");

    myRef.setValue(dataEditText.getText().toString());
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:8,代码来源:MainActivity.java

示例9: onCreate

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

    // Initialize references to views
    mToolbar = findViewById(R.id.bookmarkPageToolBar);
    mEntertainmentSpotRecyclerView = findViewById(R.id.entertainmentSpotRecyclerView);

    // Initialize  RecyclerView
    mEntertainmentSpotRecyclerView.setHasFixedSize(true);
    mEntertainmentSpotRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    // Initialize Firebase components
    FirebaseApp.initializeApp(this);
    mFireBaseDatabase = FirebaseDatabase.getInstance();
    mFirebaseAuth = FirebaseAuth.getInstance();

    mEventsDatabaseReference = mFireBaseDatabase.getReference().child("Entertainments");
    mUsersDatabaseReference = mFireBaseDatabase.getReference().child("users");
    mLikesDatabaseReference = mFireBaseDatabase.getReference().child("Likes");
    mBookmarksDatabaseReference = mFireBaseDatabase.getReference().child("Bookmarks");

    mUsersDatabaseReference.keepSynced(true);
    mEventsDatabaseReference.keepSynced(true);
    mLikesDatabaseReference.keepSynced(true);
    mBookmarksDatabaseReference.keepSynced(true);

    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Bookmarks");
    }

    //starting intent service
    startIntentService();
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:38,代码来源:BookmarkActivity.java

示例10: LocalizationService

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
LocalizationService() {
    try {
        this.test = new FireBase_DataBase();
         FirebaseDatabase database = FirebaseDatabase.getInstance();
         ref = database.getReference("");
         LocalizationRef = ref.child("Localization");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(LocalizationService.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:projets2017cl,项目名称:vc,代码行数:11,代码来源:LocalizationService.java

示例11: verifyPresence

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
public void verifyPresence(){

        final FirebaseDatabase database = FirebaseDatabase.getInstance();
        final DatabaseReference myConnectionsRef = database.getReference().child("user").child(userID).child("status");
        final DatabaseReference lastOnlineRef = database.getReference().child("user").child(userID).child("lastOnline");
        final DatabaseReference connectedRef = database.getReference(".info/connected");

        connectedRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                boolean connected = snapshot.getValue(Boolean.class);
                if (connected) {
                    DatabaseReference con = myConnectionsRef.push();

                    // when this device disconnects, remove it
                    con.onDisconnect().removeValue();

                    // when I disconnect, update the last time I was seen online
                    lastOnlineRef.onDisconnect().setValue(ServerValue.TIMESTAMP);

                    // add this device to my connections list
                    // this value could contain info about the device or a timestamp too
                    //con.setValue(Boolean.TRUE);
                    con.setValue(Boolean.TRUE);
                }
            }

            @Override
            public void onCancelled(DatabaseError error) {
                System.err.println("Listener was cancelled at .info/connected");
            }
        });
    }
 
开发者ID:codingdojoangola,项目名称:cda-app,代码行数:34,代码来源:ChatActivity.java

示例12: PresenceEventListener

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
PresenceEventListener(Context context) {
    this.context = context.getApplicationContext();
    String uuid = Uuid.get(context);
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    presenceReference = database.getReference(".info/connected");
    connectionRef = database.getReference("devices/" + uuid);
}
 
开发者ID:SimonMarquis,项目名称:FCM-toolbox,代码行数:8,代码来源:PresenceEventListener.java

示例13: onCreate

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Timber.plant(new Timber.DebugTree());
    FirebaseApp.initializeApp(this);
    FacebookSdk.setApplicationId(getString(R.string.facebook_app_id));
    FacebookSdk.sdkInitialize(this);
    instance = this;
    database = FirebaseDatabase.getInstance();

    startService(CommentTableService.createIntent(this));

}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:14,代码来源:AgroStarApplication.java

示例14: Product_TypeService

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
Product_TypeService() {
    try {
        this.test = new FireBase_DataBase();
         FirebaseDatabase database = FirebaseDatabase.getInstance();
         ref = database.getReference("");
         Product_TypeRef = ref.child("Product_Type");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Product_TypeService.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:projets2017cl,项目名称:vc,代码行数:11,代码来源:Product_TypeService.java

示例15: testDatabaseUrlWithPathInGetInstance

import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Test
public void testDatabaseUrlWithPathInGetInstance() {
  FirebaseApp app = appWithoutDbUrl("dbUrlWithPathInGetInstance");
  try {      
    FirebaseDatabase.getInstance(app, IntegrationTestUtils.getDatabaseUrl() 
        + "/paths/are/not/allowed");
    fail("no error thrown for DB URL with path");
  } catch (DatabaseException expected) { // ignore
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:11,代码来源:FirebaseDatabaseTestIT.java


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