GDKã§HelloWorldãä½ã£ã¦ã¿ã
Google ããGlass Development Kitï¼ä»¥å¾GDKï¼ãçºè¡¨ããã¦ãã°ããçµã¡ã¾ããã
åããã¦éçºè ç¨Glassã®è²©å£²ãè¡ãããä»å¾å¸å ´æå ¥ã«åãã¦ã®åããæ´»çºã«ãªããã¨ãäºæ³ããã¾ãã
ããããã®éçºè ç¨Glassã2014å¹´1ææç¹ã§æ¥æ¬ããã¯è³¼å ¥ãããã¨ãã§ãã¾ããã
USAã§ãéçºè åãã®æå¾ ã¡ã¼ã«ã§ããè³¼å ¥ãã§ããªãããã«ãªã£ã¦ãã¾ãã
å¼ç¤¾ã¯ç¾å°æ¯ç¤¾ãããçºãããã¤ãè³¼å ¥ãããã¨ãã§ãã¾ããã
Glassã使ã£ãéçºãã¦ãã¦ãå¾ã ã«æºã¾ã£ã¦ããã®ã§ãGDKã§HelloWorldãæ¸ãæ¹æ³ããä¼ããã¾ãã
ãã¦ãã¾ãä¸è¨ã
HelloWorld ãæ¸ãã®ã«ãããªã«è¦å´ããã®ã¯ä¹ ãã¶ãã§ãã
å®æãããSDKã§ããã°æ®éãHelloWorldã¨ããã®ã¯ããã¸ã§ã¯ããæ°è¦ä½æããã¨èªåçã«çæãããã¹ã±ã«ãã³ããã¸ã§ã¯ãã«ãã¡ãã¡ããã¨è¿½è¨ããã ãã§ç°¡åã«ä½ãããã®ãªã®ã§ãããç¾å¨ã®GDKï¼Rev.2ï¼ã«ã¯ã¹ã±ã«ãã³ã³ã¼ããåºåããæ©è½ãããã¾ããã
å¾ã£ã¦ä»åã¯ãGDKã®ä¸ã«å«ã¾ãããµã³ãã«ã³ã¼ãããªãã¡ã¯ã¿ãªã³ã°ããªããHelloWorldãä½ãã¾ãã
Google Glassã®éçºç°å¢
Glassã®éçºç°å¢ã¯åºæ¬çã«Androidã¨åãã§ãIDEã¯Eclipseã使ãã®ãæãç°¡åã§ãããã
Android SDK Managerãã Android 4.0.3 > GDK ãé¸æãã¦éçºç°å¢ãã¤ã³ã¹ãã¼ã«ãã¾ãã
HelloWorldãä½ã£ã¦ã¿ã
ããã§ã¯GDKã«å«ã¾ãããµã³ãã«ã³ã¼ãããªãã¡ã¯ã¿ãªã³ã°ããªããHelloWorldãä½ã£ã¦ã¿ã¾ãã
æ°è¦ããã¸ã§ã¯ã > Android Sample Project > GDK > Timer ãé¸æãã¾ããæå¾ã®ç»é¢ã§ããã¸ã§ã¯ãåãHelloWorldã«å¤ãã¦ããã¾ãã
ãã®ãµã³ãã«ã¯ãã®åã®éãã¿ã¤ãã¼ã¢ããªã§ãè¨å®ããæéãã«ã¦ã³ããã¦ã³ãããã¨ãã§ãã¾ãã
ã¾ããã¢ããªãã©ã®ãããªåä½ãããã確èªãã¾ãã
é·ç§»å³ãä½ãã¾ããã
Glassã¯ã¿ããã«ããæåå ¥åãã§ãã¾ããã®ã§å ¥åé ç®ã¯å ¨ã¦é¸æå¼ã«ãªãã¾ããå¾ã£ã¦ãã·ã³ãã«ãªã¢ããªã§ããç»é¢æ°ã¯ã¨ã¦ãå¤ããªãå¾åã«ããã¾ãã
Timerãµã³ãã«ã解æãã¦ã¿ã
次ã¯Timerãµã³ãã«ã®ã³ã¼ããè¦ã¦è¡ãã¾ãã
ã¾ãã¯Manifestããã
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.glass.sample.timer" android:versionCode="2" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" /> <application android:allowBackup="true" android:icon="@drawable/ic_timer" android:label="@string/app_name" > <activity android:name="com.google.android.glass.sample.timer.MenuActivity" android:label="@string/app_name" android:theme="@style/MenuTheme" android:enabled="true" > </activity> <activity android:name="com.google.android.glass.sample.timer.SetTimerActivity" android:label="@string/app_name" android:enabled="true" > </activity> <activity android:name="com.google.android.glass.sample.timer.SelectValueActivity" android:label="@string/app_name" android:enabled="true" > </activity> <service android:name="com.google.android.glass.sample.timer.TimerService" android:icon="@drawable/ic_timer" android:label="@string/app_name" android:enabled="true" android:exported="true"> <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_start" /> </service> </application> </manifest>
Activity ãä¸ã¤ã«Serviceãä¸ã¤å®£è¨ããã¦ãã¾ãã
ãããªã«å°ããªã¢ããªã§Activityãä¸ã¤ãããã®ã¯ä½æ ãï¼
Glassã§ã¯åºæ¬çã«Activityã¯ã³ã³ãã³ããæç»ããç®çã§ã¯ç¡ãã¡ãã¥ã¼ã表示ããç®çã§ä½¿ããã¾ããå¾ã£ã¦ãã¡ãã¥ã¼ï¼è¨å®é ç®ãé¸æé ç®ï¼ãå¢ããã¨Activityãã©ãã©ãå¢ãã¦ããå¾åãããã¾ãã
Serviceå ã®meta-dataã¯é³å£°èªèã«ããã¢ããªèµ·åããµãã¼ããã¾ãã
次ã¯ã½ã¼ã¹ã³ã¼ããè¦ã¦è¡ãã¾ãã
- MenuActivity.java
- SelectValueActivity.java
- SelectValueScrollAdapter.java
- SetTimerActivity.java
- SetTimerScrollAdapter.java
- Timer.java
- TimerDrawer.java
- TimerService.java
- TimerView.java
ãã®ä¸ã§æä½éå¿ è¦ãªã¯ã©ã¹ã¯ä»¥ä¸ã§ãã
ä¸ã¤ã®Glassã¢ããªã«ã¯å¿
ãä¸ã¤ã®ãµã¼ãã¹ãå¿
è¦ã§ãã
ãµã¼ãã¹ã§ããçºãã¢ããªãçµäºããçºã®ã¡ãã¥ã¼ãå¿
è¦ã¨ãªãã§ããããå¿
ç¶çã«ã¡ãã¥ã¼ã表示ããActivityãä¸ã¤ã¯å¿
è¦ã¨ãªãã¾ãã
ãã£ããActivityã¯ã¡ãã¥ã¼ã表示ããçºã«ä½¿ãã¨èª¬æãã¾ãããã§ã¯ãèå¿ã®ã³ã³ãã³ãã¯ã©ã®ããã«æç»ãããï¼
Glassã§ã¯Cardã¨ããAndroidã«ã¯ç¡ãä»çµã¿ãæãã¾ãã
Cardã¨ã¯
Androidã§ã¯ä¸ã¤ã®Activityã§ä¸ç»é¢ã表ç¾ãã¾ãããGlassã§ã¯ä¸ã¤ã®Cardã§ä¸ã¤ã®ç»é¢ã表ç¾ãããã¨ãã§ãã¾ãã
Cardã«ã¯Static Cardã¨Live Cardã®äºç¨®é¡ããããç»é¢ã®æ´æ°é »åº¦ã«å¿ãã¦ä½¿ãåããã¨Docã«ã¯æ¸ããã¦ãã¾ãã
Timerãµã³ãã«ã¯Live Cardãå©ç¨ãã¦ããçºãä»åã¯Live Cardã使ããã¨ã«ãã¾ãã
Live Cardã¯ä»¥ä¸ã®ãããªä»çµã¿ã«ãªã£ã¦ãã¾ãã
Glassã§ã¯ã¢ããªä¸è¦§ã並ã¶UIã®äºãTimelineã¨å¼ã³ã¾ãã
Timeline ããã¢ããªã®ãµã¼ãã¹ãèµ·åãããµã¼ãã¹ã§Live Cardãçæãã³ã³ãã³ãã®æç»ãè¡ãã¾ãã
HelloWorldãä½ã£ã¦ã¿ã
Timerãµã³ãã«ãå ã«ä½æããHelloWorldã®ããã¸ã§ã¯ãä¸å¼ã¯こちらã
éè¦ãªã®ã¯TimerServiceã®onStartCommand()ã§ããã以å¤ã¯Androidã¨å ¨ãåãã§ãã
TimerService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (mLiveCard == null) { //LiveCardãçæããã mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_TAG); //ã¬ã³ããªã³ã°ç¨Drawerã追å ããã mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mTimerDrawer); //Menuç¨Activityã®çæã¨è¿½å ãããã Intent menuIntent = new Intent(this, MenuActivity.class); menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); //LiveCardã表示ããã mLiveCard.publish(PublishMode.REVEAL); } else { // TODO(alainv): Jump to the LiveCard when API is available. } return START_STICKY; }
å°ãCardã使ããAndroidã¨åæ§ã«Activityã®ã¿ã§ã¢ããªãæ§ç¯ããæ¹æ³ãããã¾ãã
ããããã®å ´åããã®ã¾ã¾ã§ã¯Timelineããã¢ããªãèµ·åãããã¨ãã§ããªãçºãã¢ããªãèµ·åããçºã ãã®Glassã¢ããªãç¨æããå¿ è¦ãããã¾ããããã«é¢ãã¦ã¯ã¾ãå¥ã®æ©ä¼ã«æ¸ãã¾ãã
Glassã®éçºé£æ度
æ®å¿µãªããç¾æç¹ã§ã¯Glassç¨ã®ã·ãã¥ã¬ã¼ã¿ã¯ããã¾ãããå®æ©ãç¡ãã¨ã¢ããªã®ãã¹ããã§ããªãçºãæ©æ¥ãªã·ãã¥ã¬ã¼ã¿ç°å¢ã®æä¾ãæå¾ ããã°ããã§ãã
ã³ã¼ããæ¸ãäºã ããè¦ãã°ãCardã®æ¦å¿µããç解ããã°å¾ã¯Androidã¨ã»ã¨ãã©åãã§ããçºãAndroidã¢ããªéçºçµé¨è ã¯ã¹ã ã¼ãºã«éçºãè¡ããã¨ãã§ããã§ãããã
ããããå®éã«Glassã身ã«ã¤ããã¨ãããããã®ã§ããããã®æä½éã®ã¢ããªã±ã¼ã·ã§ã³ã§ããèµ·åããã¨æ¬ä½ãé常ã«ç±ããªããç¶ç¶ããè£ çãå°é£ã«ãªãã¾ãã
Glassã§å®ç¨çãªã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ããçºã«ã¯é«åº¦ãªçã¨ãã®ã¹ãã«ãè¦æ±ããããã¨ã§ãããã
ããããGlassã¯ã½ã¼ã¹ã³ã¼ããå ¬éããã¦ãã¾ããããã®çºãåºæ¬çã« Java 層ã§çã¨ããå®ç¾ããå¿ è¦ãããã¾ãã
å®é¨çãªã¢ããªã±ã¼ã·ã§ã³ã¯Androidã®å»¶é·ç·ä¸ã§ä½ãããã®ã®ãç¾æç¹ã®Glassã®æ§è½ã§å®ç¨çãªã¢ããªã±ã¼ã·ã§ã³ãFixããçºã«ã¯é常ã«é«åº¦ãªéçºã¹ãã«ãæ±ããããã¨èãã¾ãã
Java ã§çã¨ãã£ã¦ãã¢ã¡è»ã«ä½çè²»ãæ±ãããããªããã§ããã