Reputation: 6888
Steps, I have used to create my first Google Glass GDK
App
New Project
> Application name, company domain
> Next
> Glass (Glass Development Kit Preview (Google Inc.) (API 19))
> Next
> Immersion Activity
ImmersionActivity.java:
public class ImmersionActivity extends Activity {
/**
* {@link CardScrollView} to use as the main content view.
*/
private CardScrollView mCardScroller;
private View mView;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
mView = buildView();
mCardScroller = new CardScrollView(this);
mCardScroller.setAdapter(new CardScrollAdapter() {
@Override
public int getCount() {
return 1;
}
@Override
public Object getItem(int position) {
return mView;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return mView;
}
@Override
public int getPosition(Object item) {
if (mView.equals(item)) {
return 0;
}
return AdapterView.INVALID_POSITION;
}
});
// Handle the TAP event.
mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Plays disallowed sound to indicate that TAP actions are not supported.
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.playSoundEffect(Sounds.DISALLOWED);
}
});
setContentView(mCardScroller);
}
@Override
protected void onResume() {
super.onResume();
mCardScroller.activate();
}
@Override
protected void onPause() {
mCardScroller.deactivate();
super.onPause();
}
/**
* Builds a Glass styled "Hello World!" view using the {@link CardBuilder} class.
*/
private View buildView() {
CardBuilder card = new CardBuilder(this, CardBuilder.Layout.TEXT);
card.setText(R.string.hello_world);
return card.getView();
}
}
Manifest.xml:
<activity
android:name=".ImmersionActivity"
android:icon="@drawable/ic_glass_logo"
android:label="@string/title_activity_immersion" >
<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>
voice_trigger.xml:
<trigger command="SHOW_ME_A_DEMO" />
Now, what i have understood
, we can run
this app by trigger voice
command "SHOW ME A DEMO
", Is that right or wrong ?
And is there any way to run Glass GDK app on Android Emulator using Android Studio
?
Upvotes: 0
Views: 315
Reputation: 2533
Now, what i have understood, we can run this app by trigger voice command "SHOW ME A DEMO", Is that right or wrong ?
yes you could run a app with the trigger set as command = "Show_me_a_demo"
But with this you are only able to run it from the speak menu. I would turn it into
<trigger keyword="@string/app_name"/>
you could use any keyword you want but with this it would show up in the application menu as well as on the speak menu. The name that would show would be whatever you named your app.
It would also be a good idea to add <uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
to your manifest. To make sure the custom commands work
there are no emulators for the glass available as of now.
Upvotes: 1
Reputation: 7516
Now, what i have understood, we can run this app by trigger voice command "SHOW ME A DEMO", Is that right or wrong ?
It's correct. YOu can even configure this trigger and use other commands.
And is there any way to run Glass GDK app on Android Emulator using Android Studio ?
No you can't. Only Tablet, Phone, Wear (watches) and TV devices are available on the Android Virtual Device Manager.
Upvotes: 1