Before jumping into Glass dev, let’s understand how to create a Hello World project in Android Studio (AS) and run it on our device.
- Create New Project
- Get to know the guts
- Add Imports
- Add Code
- Tweak guts
- Run on Device
Create New Project
When you select New Project from the File Menu, you get this Wizard screen:

Fill in the Application Name in a natural language and the Module Name without spaces. Make sure to select API 15 for Minimum and Target SDK but Glass Development Kit Sneak Peek for Compile with.
Click Next and in the next screen just leave everything as is (the launch icon selector screen).

After that screen, leave the Blank Activity option selected and again click Next.

Finally in the Activity Name, leave MainActivity. In the Layout Name leave activity_main but also copy that activity_main over to the Fragment Layout Name, replacing fragment_main.

Everything else stays as is and Click Finish. The reason for this last bit is that new in Android is this concept of Fragments. This just complicates things for us at the moment so we will leave it out for now. We must also remove the MainActivity.java fragment method later.
Android Guts
Let’s familiarize ourselves with this screen:

Let’s review these 10 top pointers:
- Your Java Classes or Android Activities
- Layout files in xml format
- Value files for storing global settings of sorts
- AndroidManifest is a sort of Central Registry
- Top level build.gradle file
- Low level build.gradle file
- Tab bar for displayed files
- Sync Gradle file button
- Run button
- Green = A-Ok button!
import android.app.Activity;
import android.os.Bundle;
import com.google.android.glass.app.Card;
The last import as you can see is what allows us to create a Card instance, which is what Glass apps are based on. This is what you put your info into in a Glass app.
Code
Next, simply add this method inside your public class MainActivity extends Activity statement:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);Card card = new Card(this);
card.setText(“你 好 吗”);
card.setFootnote(“santiapps.com”);setContentView(card.toView());
}
Here we are creating a new card, setting its text and footnote properties and setting its view to the Activity’s ContentView or the main view.
Voila! Connect your Glass to your USB port, make sure to set it to Debug Mode ON and Run the app. It will build and install on your Glass.
Tweak
Now let’s tweak it. In your AndroidManifest, declare this intent by making that file look like this:
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.santiapps.glassapp” ><application
android:allowBackup=”true”
android:icon=”@drawable/ic_launcher”
android:label=”@string/app_name” >
<activity
android:name=”com.santiapps.glassapp.MainActivity”
android:label=”@string/app_name” >
<intent-filter>
<action android:name=”com.google.android.glass.action.VOICE_TRIGGER” />
</intent-filter>
<meta-data android:name=”com.google.android.glass.VoiceTrigger”
android:resource=”@xml/voice_trigger” />
</activity>
</application></manifest>
I’ve pasted my entire file here so as to clear up as much as I can. Basically you just need to add the intent-filter and its metadata elements.
Let’s make it more interesting! As with our First Android App tutorial, let’s add some user interaction in Part 2.
Hi there, just became aware of your blog thru Google, and located that it’s truly informative. I am gonna be careful for brussels. I will be grateful if you happen to continue this in future. A lot of people can be benefited from your writing. Cheers!
[…] First Google Glass App – Part 7 – Bridge to Glass App GDK Development | Quique's iO… […]