Month: June 2018

Sign Up & Login App using Android Architecture Components

Anybody looking for a simple app that does the following :

  1. When the App is launched for the first time, it needs to you to sign up by providing a username and password.
  2. After that, the app asks you to login by verifying the provided username and password.

The code for the app can be found at https://github.com/djain2405/SignUp-Login in both Java and Kotlin. The app is written using the Android Architecture components in the following pattern :

LifeCycleOwner(Activity) -> ViewModel -> Repository -> Database using Room Library

These are the benefits I found using this architecture for the app :

  • Eliminating problems due to configuration Change
  • Avoiding writing tons of boilerplate code
  • Avoiding memory leaks
  • Data persistence
  • Scalable. Separation of concerns allows changes to be made easily in any component without affecting the whole app.

Toast.show() not showing anything!

I recently came across this fact:

Inside a button On Click, I am trying to show a toast like below

Toast.makeText(getBaseContext(), "My message to show!", Toast.LENGTH_LONG).show();

Clicking on the button, did not show any toast. This is what I learnt as things to remember when showing a toast while debugging this issue :

  1. Make sure not to forget to call show() after the makeText.
  2. Check for the Context , if its the right one.
  3. The most important one , make sure your Android Notifications are on for your app, else the Toast will not be shown.