在onStop中输入数据时的无限循环

时间:2017-12-14 14:24:42

标签: android firebase android-viewpager

在项目中,我有1个mainActivity和4个片段。 使用ViewPager作为bottomNavbar打开Fragmentes。 我在项目中使用FireBase。当我第一次登录时,我使用在mainActivity上打开的fragmentte recyclerview列出数据。 但是当您使用mAuth.SignOut退出应用程序时,会出现登录屏幕。在此屏幕上输入后,onStop方法进入无限循环。应用程序将不断打开片段并返回mainActivity。

当我尝试使用onStop Toast时,它会在第一次启动时打印。如果没有代码在onStop中添加firebase数据,则没有问题。但是我需要添加onStop来进行“在线”检查。

12-14 21:08:07.237 2004-2004/com.example.hasan.simpleblog I/LoginActivity: Login 

12-14 21:08:07.267 2004-2117/com.example.hasan.simpleblog V/FA: Activity paused, time: 24612278

12-14 21:08:07.307 2004-2004/com.example.hasan.simpleblog V/FA: onActivityCreated
12-14 21:08:07.327 2004-2117/com.example.hasan.simpleblog V/FA: Using measurement service
12-14 21:08:07.327 2004-2117/com.example.hasan.simpleblog V/FA: Connection attempt already in progress
12-14 21:08:07.337 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: ActivityMAin onCreate 
12-14 21:08:07.337 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: ActivityMAin mDatabaseUser 
12-14 21:08:07.357 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: ActivityMain SetupViewPager
12-14 21:08:07.357 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: ActivityMAin onStart 

12-14 21:08:07.357 2004-2117/com.example.hasan.simpleblog V/FA: Activity resumed, time: 24612375

12-14 21:08:07.717 2004-2004/com.example.hasan.simpleblog I/android:switcher:2131231057:0: onCreate Main FRAGMENT
-
12-14 21:08:07.847 2004-2117/com.example.hasan.simpleblog V/FA: Activity paused, time: 24612872
-
12-14 21:08:07.927 2004-2004/com.example.hasan.simpleblog V/FA: onActivityCreated
12-14 21:08:07.957 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onCreate oldu
12-14 21:08:07.957 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main mDatabaseUser oldu
12-14 21:08:07.957 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Burası Main SetupViewPager
12-14 21:08:07.957 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onStart oldu
12-14 21:08:07.957 2004-2117/com.example.hasan.simpleblog V/FA: Activity resumed, time: 24612979


12-14 21:08:07.987 2004-2004/com.example.hasan.simpleblog I/android:switcher:2131231057:0: onCreate Main FRAGMENT

12-14 21:08:08.287 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.287 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:08.307 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.307 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent

12-14 21:08:08.507 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.507 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:08.517 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.517 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:08.517 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.597 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.647 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.647 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:08.657 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:08.657 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.657 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.657 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:08.657 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:08.667 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.667 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.667 2004-2004/com.example.hasan.simpleblog I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@7278bbf time:18352916
12-14 21:08:08.677 2004-2004/com.example.hasan.simpleblog I/System.out: ---------------------------OnStop----------------------------
12-14 21:08:08.677 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: #3 mView = null
12-14 21:08:08.677 2004-2004/com.example.hasan.simpleblog I/Timeline: Timeline: Activity_launch_request id:com.example.hasan.simpleblog time:18352927
12-14 21:08:08.727 2004-2117/com.example.hasan.simpleblog V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 771
12-14 21:08:08.727 2004-2117/com.example.hasan.simpleblog V/FA: Activity paused, time: 24613750
12-14 21:08:08.747 2004-2004/com.example.hasan.simpleblog V/FA: onActivityCreated
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onCreate oldu
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main mDatabaseUser oldu
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Burası Main SetupViewPager
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onStart oldu
12-14 21:08:08.787 2004-2117/com.example.hasan.simpleblog V/FA: Activity resumed, time: 24613808
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{bd3b772 I.E...... R.....ID 0,0-0,0}
12-14 21:08:08.787 2004-2004/com.example.hasan.simpleblog D/SecWifiDisplayUtil: Metadata value : none
12-14 21:08:08.797 2004-2004/com.example.hasan.simpleblog I/android:switcher:2131231057:0: onCreate Main FRAGMENT
12-14 21:08:08.847 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.847 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.857 2004-2004/com.example.hasan.simpleblog W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
12-14 21:08:08.887 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
12-14 21:08:08.927 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.927 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:08.937 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:08.937 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:08.937 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.987 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:08.997 2004-2004/com.example.hasan.simpleblog I/Timeline: Timeline: Activity_launch_request id:com.example.hasan.simpleblog time:18353247
12-14 21:08:09.027 2004-2117/com.example.hasan.simpleblog V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 245
12-14 21:08:09.027 2004-2117/com.example.hasan.simpleblog V/FA: Activity paused, time: 24614052
12-14 21:08:09.047 2004-2004/com.example.hasan.simpleblog V/FA: onActivityCreated
12-14 21:08:09.087 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onCreate oldu
12-14 21:08:09.087 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main mDatabaseUser oldu
12-14 21:08:09.087 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Burası Main SetupViewPager
12-14 21:08:09.087 2004-2004/com.example.hasan.simpleblog I/com.example.hasan.simpleblog: Main onStart oldu
12-14 21:08:09.087 2004-2117/com.example.hasan.simpleblog V/FA: Activity resumed, time: 24614111
12-14 21:08:09.087 2004-2004/com.example.hasan.simpleblog D/SecWifiDisplayUtil: Metadata value : none
12-14 21:08:09.097 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{689b9c7 I.E...... R.....ID 0,0-0,0}
12-14 21:08:09.107 2004-2004/com.example.hasan.simpleblog I/android:switcher:2131231057:0: onCreate Main FRAGMENT
12-14 21:08:09.147 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.147 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.147 2004-2004/com.example.hasan.simpleblog W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
12-14 21:08:09.167 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
12-14 21:08:09.167 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:09.187 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:09.187 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:09.197 2004-2004/com.example.hasan.simpleblog I/System.out: Before addListenerForSingleValueEvent
12-14 21:08:09.197 2004-2004/com.example.hasan.simpleblog I/System.out: After addListenerForSingleValueEvent
12-14 21:08:09.197 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.217 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.277 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.277 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:09.277 2004-2004/com.example.hasan.simpleblog I/System.out: In onDataChange
12-14 21:08:09.287 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.287 2004-2004/com.example.hasan.simpleblog E/RecyclerView: No adapter attached; skipping layout
12-14 21:08:09.287 2004-2004/com.example.hasan.simpleblog I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1269f06 time:18353538
12-14 21:08:09.287 2004-2004/com.example.hasan.simpleblog I/System.out: ---------------------------OnStop----------------------------
12-14 21:08:09.297 2004-2004/com.example.hasan.simpleblog D/ViewRootImpl: #3 mView = null
12-14 21:08:09.307 2004-2004/com.example.hasan.simpleblog I/System.out: ---------------------------OnStop----------------------------


 @Override
public void onStop() {

        mDatabaseUsers.child(mAuth.getCurrentUser().getUid()).child("online").setValue(ServerValue.TIMESTAMP);

    super.onStop();
}  

0 个答案:

没有答案