MainActivity.java - Updated to include all working code.