Android: Firebase Update Issue When the app is in background

前端 未结 1 1622
长情又很酷
长情又很酷 2021-01-29 04:19

Hey I m going to develop an location tracker app in which, this app in client device which constantly send it location to the firebase db. Here the problem is that it will send

相关标签:
1条回答
  • 2021-01-29 05:08

    To get more information about why the database writes are not completing after 3 minutes, add a CompetionListener to your setValue():

    reference.setValue(mLocations, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
            if (databaseError == null) {
                Log.i(TAG, "onComplete: OKAY");
            } else {
                Log.e(TAG, "onComplete: FAILED " + databaseError.getMessage());
            }
        }
    });
    

    When you hit the 3 minute mark, if the callback fires with an error, such as permission failure, you can investigate why. If it stops firing at all, that probably means you've lost connection with the Firebase server. You can monitor the connection status using a listener, as described in the documentation.

    0 讨论(0)
提交回复
热议问题