Start a new topic

Android login to Kinvey account questions

I’m able to login to my Kinvey account using the Android APIs, but I had some questions on how the login process works. The Android guide says the “library automatically cache’s the user’s name and a current authorization token in a saved credential store.” The first question I have is how long is the user information cached? I would prefer to not have to save the user’s password, but I don’t want them to have to login frequently.


The second question I have is what is the best way to check if a user is logged in? I didn’t see any API calls for login check.


The last question I have is do I need to make the user login again after they register?


Thanks for the time!



Sorry for the delay. Here is the code I use in my global class. I only use getInitialClient at app startup to check if the display should go to the login view or the home screen.


  

public void getInitialClient(Context mainContext, int displayview) {

        mainActivityContext = mainContext;
        displayviewInt = displayview;

        client = new Client.Builder(this.getApplicationContext()).setRetrieveUserCallback(new KinveyUserCallback() {      
            @Override
            public void onSuccess(User result) {

                Log.d(TAG, "Kinvey load complete. Load client user is: " + result.getUsername());       

                if (result.isUserLoggedIn()) {
                    Log.d(TAG, "Kinvey user logged in - display home");

                    //code to display home screen

                } else {
                    Log.d(TAG, "Kinvey user not logged in - display settings");

                    //code to display login screen
                }
            }

            @Override
            public void onFailure(Throwable error) {
                Log.d(TAG, "Kinvey Build failure");

            }
        }).build();

    }   

  

Login or Signup to post a comment