Android 2.2的SDK - Droid X的摄像头活动未正常完成 [英] Android 2.2 SDK - Droid X Camera Activity doesn't finish properly
问题描述
我注意到了默认的摄像头的活动我请一个Droid X的不同,看起来比那个在我的Droid和Nexus One的。选择OK大家对Droid和Nexus One后,该活动会完成 - 在Droid X有一个完成按钮(这需要你背对着镜头,而不是结束的活动),并获得到的唯一途径屏幕我想是打了后退按钮。
下面是在Android 2.2 / 2.3,工程类,但不适合的Droid X的:
包com.android.xxx;
进口的java.io.File;
进口android.content.Intent;
进口android.net.Uri;
进口android.os.Bundle;
进口android.os.Environment;
进口android.provider.MediaStore;
进口android.view.Window;
公共类CameraView扩展MenusHolder {
保护字符串_path;
保护布尔_taken;
受保护的静态最后弦乐PHOTO_TAKEN =photo_taken;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
的setContentView(R.layout.create_event_view);
/ *
*保存到SD
* /
文件imageDirectory =新的文件(
Environment.getExternalStorageDirectory()+/ mypath中/);
imageDirectory.mkdirs();
/ *
*温度图像覆盖每个时间换空间
* /
_path = Environment.getExternalStorageDirectory()
+/MyPath/temporary_image.jpg;
startCameraActivity();
}
保护无效startCameraActivity(){
档案文件=新的文件(_path);
乌里outputFileUri = Uri.fromFile(文件);
意向意图=新的意图(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri);
startActivityForResult(意向,0);
}
@覆盖
保护无效onActivityResult(INT申请code,INT结果code,意图数据){
开关(结果code){
情况下0:
的setResult(5);
完();
打破;
情况1:
onPhotoTaken();
打破;
}
}
保护无效onPhotoTaken(){
_taken = TRUE;
的setResult(0);
完();
}
@覆盖
保护无效的onSaveInstanceState(包outState){
outState.putBoolean(CameraView.PHOTO_TAKEN,_taken);
}
@覆盖
保护无效onRestoreInstanceState(包savedInstanceState){
如果(savedInstanceState.getBoolean(CameraView.PHOTO_TAKEN)){
onPhotoTaken();
}
}
}
多德...这只是一个错误。我有同样的问题,有没有办法解决办法的。它有时工作,有时没有。我问了摩托罗拉的人寻求帮助,他们说,有一个为Android的那些图像的支持。
I noticed the default camera activity I call on a Droid X is different looking than the one on my Droid and Nexus One. After selecting "OK" on the Droid and Nexus One, the activity would finish - the Droid X has a "Done" button (which takes you back to the Camera, instead of finishing the activity), and the only way to get to the screen I want is to hit the "Back" button.
Here is the class that works on Android 2.2/2.3, but not for Droid X's:
package com.android.xxx;
import java.io.File;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Window;
public class CameraView extends MenusHolder {
protected String _path;
protected boolean _taken;
protected static final String PHOTO_TAKEN = "photo_taken";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.create_event_view);
/*
* save to sd
*/
File imageDirectory = new File(
Environment.getExternalStorageDirectory() + "/MyPath/");
imageDirectory.mkdirs();
/*
* temp image overwrites each time for space
*/
_path = Environment.getExternalStorageDirectory()
+ "/MyPath/temporary_image.jpg";
startCameraActivity();
}
protected void startCameraActivity() {
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
case 0:
setResult(5);
finish();
break;
case -1:
onPhotoTaken();
break;
}
}
protected void onPhotoTaken() {
_taken = true;
setResult(0);
finish();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean(CameraView.PHOTO_TAKEN, _taken);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState.getBoolean(CameraView.PHOTO_TAKEN)) {
onPhotoTaken();
}
}
}
Dude... it's just a bug. I had the same problem and there's no way to workaround that. It sometimes work, and sometimes it does not. I asked the Motorola's guy for help and they said that there's no support for those Android images.
这篇关于Android 2.2的SDK - Droid X的摄像头活动未正常完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!