How to Create Google Glass Options Menu

In this tutorial I am going to explain how to display menu items on google glass. Displaying options menu on glass is very simple. The menu we are going to create contains three menu items where selecting each menu items performs separate action.

5. Now create an xml file named main.xml under res ⇒ menu folder. In this file we declare actual menu items. We are going to add three menu items about, settings and quit. The first two menu items will launch two separate activities and the third option will quit the app.

7. Now open your main activity class (MainActivity.java) and do the below changes. On Glass, menus can be triggered using the same methods which we use when developing mobile app.

Here user tap on D-Pad is detected using KEYCODE_DPAD_CENTER key event inside onKeyDown() method. Then by calling openOptionsMenu() method, menu is rendered on to glass screen. Finally the appropriate action for menu item selection is taken place in onOptionsItemSelected() method.

Now deploy the app on to Google Glass and launch the app by saying Ok Glass Menus. Once the app is launched, if you tap on D-Pad you can the menu opened. You can swipe forward / backward to see other menu options.

Hi there! I am Founder at androidhive and programming enthusiast. My skills includes Android, iOS, PHP, Ruby on Rails and lot more. If you have any idea that you would want me to develop? Let’s talk: ravi@androidhive.info

respect to u from Lebanon 🙂 its great that you are creating a new google glass tutorial but please don`t forget the main reason that people come to the site androidhive ,
thank you for your understanding

Andrew

Kindly post android app tutorial I always visit your blog for those and they are really helpful seeing google glass tutorial’s are disappointing as the name suggest’s ANDROIDHIVE

Sara

Miss Ravi Tamada can you tell me that from now onwards only google glass tutorials will be uploaded so that i should not get my hopes high

Nicky

Sara i am completely agree with you, tutorials are really good but i think google glass is really not a future, ravi please focus android app developement

Sara, You need to understand one thing. I have to cover all the android things. Glass is one of the android device. Not having a Glass with you doesn’t mean that Glass tutorials are not important. You won’t comment this having glass device with you.

One last thing there are not many developers on glass. I just wanted to help the glass developers with the knowledge I have.

Thanks

سامر

its okay that focus on glass, but it like your ignoring android app tutorial , im not seeing any new one for a while , im really said that will maybe will loose some great user for this site

Sam

Nice one, Go ahead 🙂

Adachi

Thank you for your effort, it will be amazing if you post some tutorials for Google Wear as well

Pindat

What about android mobile app development ?

Sana

This blog is all about android and man you are going in the other direction millions of people came here to see the amazing world of android seeing the glass thingy is a bit of disappointment and your previous three tutorials were sadly not about android at all kindly consider this view point

Ofir

Ravi, can you make a tutorial of building a chat app?

Arjun

I request you to make a single tutorial which includes all the concepts covered in androidhive till now such as “navigation drawer, list (or) gridview, menus, dialogs, action bar with icons on it to perform some task, etc etc concepts. If you build a tutorial by integrating all these concepts in a single app then i would be very greatful to you because it will be very helpful for the beginner to know how to integrate all these concepts when one builds an app. I’ve come across many people who are following androidhive and also are very good in each and every concept but the irony is they dont know how to integrate all these concepts in single app. So , i request you build such a tutorial which will integrate all these concepts and one can easily learn by looking at that. Thank you

PS: Hello Ravi, Please make this kind of tutorial as requested above and give us a single app which includes all these concepts. Good luck. Better late then never. Thank you

Mela

Looks like some one bought google glass :-p Hey dude stop this man make some android tut’s make some design tutorial’s some animation tut’s like mean really cool one like goole plus animation and diff apps

Thanks Yo
#WeLoveAndroid

Peru Tamilea

I love you but please stop google glass !!!!! I have two with me but we want android app tutorials