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
You can do both. If you set it just once then it should be here. Anywhere else and your app will crash. Debugger will say that you have not setAndroidContext():
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Firebase.setAndroidContext(this);
// The rest of your code goes here
If you want to use for multiple activities then create a class that has the same name as the app, make sure that the class extends Application.
public class NameOfApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Firebase.setAndroidContext(this);
}
}
After that update the application tag in the manifest.xml file with the following:
android:name=".NameOfApp"