I modified the StopWatch demo Glass app to start the Camera activity via request when the side is tapped. The intent code is copied from Google's documentation.
When I tap, the onPause callback for my app is fired, but the screen transitions to black instead of a camera preview. Tapping again does nothing—onResume is not called. Swiping down does transition me back to the StopWatch activity, however.
Does this look like a bug with the camera intent on Glass, or is it something on my end?
StopWatch Activity
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);
}
}
AndroidManifest
<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>
Logcat
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
It looks like your code is correct. Please file a bug report on our issues tracker .
As an alternative, you may want to try using the Camera class directly to capture photos.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With