我正在尝试使用 ADT 中的模拟器来测试一个拍照的应用程序,我能够启动相机,但是在拍照并单击“确认”按钮后 logcat 会引发错误:
08-21 13:46:18.933: E/SoundPool(289): 错误加载 /system/media/audio/ui/Effect_Tick.ogg
在此之后,我的应用程序中的回调事件不会被调用,我无法获取图片,但是我可以单击“取消”并使用代码 RESULT_CANCELED 调用回调。
这是我的代码(部分):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages");
imagesFolder.mkdirs(); // <----
File image = new File(imagesFolder, "image_001.jpg");
Uri fileUri = Uri.fromFile(image);
i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(i, 100);
...
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == 100){
if (resultCode == RESULT_OK){
} else if (resultCode == RESULT_CANCELED){
} else {
}
}
}
我“可以”在真实设备上测试我的代码,但我真的很想修复我的模拟器,知道该怎么做吗?
- 编辑 -
这是我的 AVD 的配置文件:
avd.ini.encoding=ISO-8859-1
hw.dPad=no
hw.lcd.density=320
sdcard.size=200M
hw.cpu.arch=arm
hw.device.hash=298918422
hw.camera.back=emulated
disk.dataPartition.size=200M
skin.dynamic=yes
skin.path=768x1280
hw.keyboard=yes
hw.cpu.model=cortex-a8
hw.ramSize=768
hw.device.manufacturer=Google
hw.sdCard=yes
hw.mainKeys=no
hw.accelerometer=yes
skin.name=768x1280
abi.type=armeabi-v7a
hw.trackBall=no
hw.device.name=Nexus 4
hw.battery=yes
hw.sensors.proximity=yes
image.sysdir.1=system-images\android-18\armeabi-v7a\
hw.sensors.orientation=yes
hw.audioInput=yes
hw.camera.front=emulated
hw.gps=yes
vm.heapSize=64
我还在清单中添加了以下标记:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />