Now i\'m trying to make like a instagram chat program using firebase the problem is i want to show that member login status but android life cycle is problem
Here
Put this dependency in your build.gradle file:
implementation "android.arch.lifecycle:extensions:*"
Then in your Application class, use this:
public class MyApplication extends Application implements LifecycleObserver {
@Override
public void onCreate() {
super.onCreate();
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
private void onAppBackgrounded() {
Log.d("MyApp", "App in background");
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
private void onAppForegrounded() {
Log.d("MyApp", "App in foreground");
}
}
Update your AndroidManifest.xml file:
When your app is in background change status to
offlineand when app is in foreground change it's status toonline.
Reference