The QR code will be shown in a separate activity. Let’s create a new blank activity and name it ResultActivity. For now let’s leave the layout XML with the default content but let’s add a few constants to the class file. Locate and open ResultActivity.java, then add the 3 static final strings as shown below:
When the “Generate” button is tapped, the first thing to do is to hide the keyboard, if it is showing. And then show the QR code in a separae activity. First, open MainActivity and add the following code to hide the keyboard using the InputMethodManager :
Then create the generateQrCode method to show QR code in the ResultActivity after passing the data set by the user as extras for the intent.
Remember to set the listener for the "Generate" button – in setListeners(), add:
If you run the app now, you will be able to see the result activity opened. Of course, it will be empty since we have not yet added anything to it or its layout.