Update MainActivity.java

Changed code and resolved error.