Using Vuzix HUD API Resources and Packages
  • 05 Sep 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Using Vuzix HUD API Resources and Packages

  • Dark
    Light

Article summary

It is recommended that you utilize Vuzix libraries to design your user experience. Adding these libraries to your Android project is simple and developer friendly. Vuzix provides a Jitpack repository for those libraries and other resources.


Adding HUD-ActionMenu and HUD-Resources to your Android Application

To be able to utilize the HUD-ActionMenu and HUD-Resources libraries, you will need to add a dependency in your application build.gradle file.

In your app's build.gradle file just add the following line to your dependencies section:

  • implementation 'com.vuzix:hud-actionmenu:**Version'

    The latest **version is:

Note that adding HUD-ActionMenu to your project will automatically add HUD-Resources to your project. Your build.gradle for your application will look something like this:

apply plugin: 'com.android.application' 
android {
	compileSdkVersion 30 defaultConfig {
		applicationId "com.vuzix.blade2.devkit.camera_sample"
		minSdkVersion 30
		targetSdkVersion 30
		versionCode 1
		versionName "1.0"
	}
	buildTypes {
		release {
			minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
		}
	}
}
dependencies {
	implementation 'com.vuzix:hud-actionmenu:**Version'
}


Android Jetpack Compatibility

Beginning with version 2.0, the HUD-ActionMenu and HUD-Resources libraries support Android Jetpack. In addition, the HUD themes are based on Theme.AppCompat rather than Theme.Material.

If you are not using Jetpack in your application, you should not upgrade past version 1.6 of the HUD libraries. If you choose to migrate to Jetpack in the future, you can also upgrade to the latest HUB libraries at that time.


Determining Blade Model

Using the Utils class of the HUD-Resources library, you can quickly determine which model of the Blade your application is currently running on.
This is particularly useful if your application provides the user feedback (i.e. audio or haptic feedback).

To do this, simply call the Utils class using the method described below:

if(Utils.getModelNumber() == Utils.DEVICE_MODEL_BLADE) {
	//This app is currently running on a Blade with Haptic Feedback
}
else if(Utils.getModelNumber() == Utils.DEVICE_MODEL_BLADE_REV_2020) {
	//This app is currently running on a Blade Upgraded with Stereo Speakers
}
else if(Utils.getModelNumber() == Utils.DEVICE_MODEL_BLADE_2) {
	//This app is currently running on a Blade 2 with Stereo Speakers
}


Utilizing the HUD Themes

With the HUD-Resource library in your project, you can now use the HUD theme as your main application theme. You also have access to a"light" variation of the HUD theme.

These themes will provide a good base for your application design and will also provide the color scheme as the default one for your layout.

To use the HUD theme as the main theme of the application, you just need to modify the Application Manifest and ensure the android:theme is "@style/HudTheme".

Your Android Manifest will look something like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vuzix.blade2.devkit.camera_sample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/HudTheme">
<activity android:name=".MainActivity"> 
<intent-filter>\
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>


Utilizing HUD API Classes

The Vuzix HUD libraries include our customized versions of Activity classes and other frequently used classes.

Our extension of those classes provide extra functionality, improve performance and add custom features to take full advantage of the Blade 2 platform.

We recommend that all your Activities extend the "ActionMenuActivity". Your Main Activity Class definition will look something like this:

public class MainActivity extends ActionMenuActivity { 
. . .
}


Changing Action Menu Color

Beginning with version 1.5 of the HUD-ActionMenu library, you can easily change the color of the action menu. To do so, override actionMenuColor in your own theme:

<style name="AppTheme" parent="HudTheme"> 
<item name="actionMenuColor">
	@color/hud_red</item>
</style>

If you have two themes, for example light and dark mode themes, don't forget to define actionMenuColor in both themes.

If you want to customize the action menu beyond simple color changes, you will need to use custom views for the action menu items.


HUD Libraries Java Docs

For more information and details check our Javadocs for the HUD Libraries:


Was this article helpful?