側面がタップされたときにリクエストを介してカメラ アクティビティを開始するように、StopWatch デモ Glass アプリを変更しました。インテント コードは、Google のドキュメントからコピーされます。
タップすると、アプリの onPause コールバックが起動されますが、画面がカメラ プレビューではなく黒に変わります。もう一度タップしても何も起こりません — onResume は呼び出されません。ただし、下にスワイプすると StopWatch アクティビティに戻ります。
これは、Glass に対するカメラの意図によるバグのように見えますか、それとも私の問題ですか?
ストップウォッチ アクティビティ
private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; // 1337 also doesn't work
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // file:///mnt/sdcard/Pictures/MyCameraApp/IMG_20130812_105617.jpg
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
return true;
default:
return super.onKeyDown(keyCode, event);
}
}
Androidマニフェスト
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.glass.samples.stopwatch"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="com.google.glass.samples.stopwatch.StopWatchActivity"
android:label="StopWatch" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
ログキャット
470 862-862/com.google.glass.samples.stopwatch D/GOOGLE1: Touched side
470 862-862/com.google.glass.samples.stopwatch D/GOOGLE1: Pause
533 862-862/com.google.glass.samples.stopwatch D/OpenGLRenderer: Flushing caches (mode 1)
611 190-216/? I/ActivityManager: Displayed com.google.glass.camera/.CameraApiActivity: +142ms
619 862-862/com.google.glass.samples.stopwatch D/OpenGLRenderer: Flushing caches (mode 0)
142 190-213/? I/power: *** set_screen_state 0