Java 摄像机意图后显示黑屏
我修改了秒表演示玻璃应用程序,在点击侧面时通过请求启动相机活动。意图代码是从谷歌的文档中复制的 当我点击时,我的应用程序的onPause回调将被触发,但屏幕将变为黑色,而不是相机预览。在未调用Resume时,再次点击不会产生任何效果。不过,向下滑动确实会将我转换回秒表活动 这看起来像是一个镜头对准玻璃的虫子,还是我这边的什么东西 秒表活动Java 摄像机意图后显示黑屏,java,android,google-glass,Java,Android,Google Glass,我修改了秒表演示玻璃应用程序,在点击侧面时通过请求启动相机活动。意图代码是从谷歌的文档中复制的 当我点击时,我的应用程序的onPause回调将被触发,但屏幕将变为黑色,而不是相机预览。在未调用Resume时,再次点击不会产生任何效果。不过,向下滑动确实会将我转换回秒表活动 这看起来像是一个镜头对准玻璃的虫子,还是我这边的什么东西 秒表活动 private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; // 1337 als
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>
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
看起来你的代码是正确的。请在我们的计算机上提交错误报告
或者,您可能希望尝试直接使用该类来捕获照片。您可以在此处启动该问题: