How to Create Google Glass Options Menu in Android?
Last Updated :
28 Apr, 2025
Google Glass is a wearable device developed by Google that allows users to perform various tasks such as taking photos, recording videos, and sending messages. In this article, we will show you how to create a Google Glass options menu in Android.
Step By Step Implementation
Step 1: To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: In the MainActivity.java file, create a new method called "createOptionsMenu()". This method will be used to create the options menu that will be displayed when the user taps on the touchpad of Google Glass.
Java
@Override public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar
// if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
Step 3: In the res/menu folder, create a new XML file called "main.xml". This file will define the options that will be displayed in the menu.
XML
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_photo"
android:title="Take Photo"
android:showAsAction="always" />
<item
android:id="@+id/menu_video"
android:title="Record Video"
android:showAsAction="always" />
<item
android:id="@+id/menu_message"
android:title="Send Message"
android:showAsAction="always" />
</menu>
Step 4: In the MainActivity.java file, create new methods called "takePhoto()", "recordVideo()", and "sendMessage()". These methods will be called when the user selects the corresponding menu items.
Java
public void takePhoto() {
// code to take a photo
}
public void recordVideo() {
// code to record a video
}
public void sendMessage() {
// code to send a message
}
Step 5: In the MainActivity.java file, override the "onOptionsItemSelected()" method. This method will be called when the user selects a menu item.
Java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_photo:
takePhoto();
return true;
case R.id.menu_video:
recordVideo();
return true;
case R.id.menu_message:
sendMessage();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
That's it! You have successfully created a Google Glass options menu in Android. When the user taps on the touchpad of Google Glass, the options menu will be displayed. The user can then select one of the options and the corresponding method will be called. It is worth noting that Google Glass is no longer being developed, and the device is no longer available for purchase.
Similar Reads
How to Create Option Menu in Android using Kotlin? In this article, we will learn how to create an options menu in the Android app using Kotlin. To have an options menu in an Activity, we need to create a new menu XML file and inflate it using menuInflator.inflate( ) method. In menu.xml we will design the options menu as the requirement of the app.
2 min read
How to Create Google Sign In UI using Android Studio? Nowadays, android apps are very popular. This UI has generally seen in the âGoogle Sign Inâ App. In this article, we will create a Google Sign UI in Android. Below are the various steps on how to do it. This will help the beginner to build some awesome UI in android by referring to this article. St
3 min read
How to Create Google Lens Application in Android? We have seen the new Google Lens application in which we can capture images of any product and from that image, we can get to see the search results of that product which we will display inside our application. What are we going to build in this article? We will be building a simple application in w
10 min read
How to Create a New Fragment in Android Studio? Android Studio is the official integrated development environment for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. You can Develop Android App using this. Here, We are going to learn how to create a new Fragment in A
2 min read
How to Customize Option Menu of Toolbar in Android? In this article, we will see how to add icons and change background color in the options menu of the toolbar. Option menu is a collection of menu items of an activity. Android Option Menus are the primary menus of the activity. They can be used for settings, search, delete items, etc. We will first
3 min read