A (175)

(Tuis.) #1

622 CHAPTER 16: The Future of Android: The 64-Bit Android 5.0 OS


To create your menu object, you have the “standard” (across 32-bit and 64-bit Android OSs) public
boolean onCreateOptionsMenu( ) method, which calls the .inflate( ) method off of the Menu class
getMenuInflater( ) method and passes the XML Menu object definition using the standard
/res/menu/hello.xml definition file and a Menu object named menu, just as you learned how to do
during the course of this book.


Finally, you have the public boolean onOptionsItemSelected( ) method that passes in the MenuItem
object named item. The only difference in this code from what you have used before is that the MenuItem
object is evaluated using an if-then-else evaluation code construct rather than a switch-case code
construct. The reason this was done is that most switch-case statements use constant expressions,
whereas if-then-else statements can use variables, as you can see by the int id = item.getItemId();
line of code in Figure 1 6-2 7. If you like using the switch-case approach, this should work in Android 5.0
and later as well, as both decision logic structures are supported in Java. A primary difference is that
switch-cases use constants, whereas if-then-else statements can use variables.


Now that you have created and explored a new Android 5.0 application project, structure, markup,
and Java code, you can learn how to upgrade the Android Studio. While I was writing this chapter,
version 0.8.2 became available, so I am going to take the opportunity to show the work process
involved in updating Android Studio using an IntelliJ IDEA, which is slightly different than how this is
done using the Eclipse ADT IDE.


Updating the Android Studio IntelliJ IDEA


The Check for Updates feature is in the same place in IntelliJ and Eclipse (and every other software
package), which is on the Help menu, as shown in Figure 1 6-2 8. You use a Help ➤ Check for Update
menu sequence to invoke the IDEA updates from the repository, and you can use the Help ➤ About
menu sequence to see the number of your current IDEA version, which you’ll do right before you
check for Android Studio updates. This will allow you to see the before and after result of the update
from 0.8.0 to 0.8.2, which you are going to apply next.


Figure 16-28. Use the Help ➤ Check for Update menu sequence in Android Studio (IntelliJ) to check for updates

Free download pdf