I\'m trying to play a bit with Firebase and Android.
I have one RegisterActivity, and one MainActivity.
My current flow is - start with M
As seen in the sample applications of Firebase you should place it inside your Application.
package com.firebase.androidchat;
import com.firebase.client.Firebase;
/**
* @author Jenny Tong (mimming)
* @since 12/5/14
*
* Initialize Firebase with the application context. This must happen before the client is used.
*/
public class ChatApplication extends android.app.Application {
@Override
public void onCreate() {
super.onCreate();
Firebase.setAndroidContext(this);
}
}
Source
Firebase.getAndroidContext()
After setting the Application context once you can use it where ever you need it. You can retrieve it as often as you like, everywhere.
I would also recommend to use the Firebase.getAndroidContext() instead of storing it into variables to prevent MemoryLeaks