May 2017
Beginner to intermediate
238 pages
4h 56m
English
Now, let's test out our hardware buttons along with a Toast example. Don't feel hungry yet reading Toast! It's not the one that you are going to eat. A Toast is a message that gets displayed on your screen for a few seconds and disappears. You will see what it is in a few minutes. So, now open up your FullscreenActivity.java file where you typed your onCreate code, and after your onCreate method, type the following:
@Override public void onBackPressed() { // your code. Toast.makeText(FullscreenActivity.this, "Back button pressed", Toast.LENGTH_SHORT).show(); }
Observe the code here. In the first line, we have used the keyword @Override. This is because we are overriding the parent class functionality, which is the ...
Read now
Unlock full access