Vai*_*ani 14 java camera android
这是我简单的Camera Intent Demo,其中我只有一个Activity .....
package x.y;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
public class PhotoShoot extends Activity {
final static int CAMERA_RESULT = 0;
ImageView imv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAMERA_RESULT);
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK)
{
Bundle extras = intent.getExtras();
Bitmap bmp = (Bitmap) extras.get("data");
imv = (ImageView) findViewById(R.id.ReturnedImageView);
imv.setImageBitmap(bmp);
}
}
}
Run Code Online (Sandbox Code Playgroud)
和Layout main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/ReturnedImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
清单......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="x.y"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PhotoShoot"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
在Android模拟器2.2中从几秒钟开始"强制关闭" 从相机意图开始以及以下异常......
07-06 15:26:00.999: ERROR/AndroidRuntime(544): FATAL EXCEPTION: GLThread 11
07-06 15:26:00.999: ERROR/AndroidRuntime(544): java.lang.IllegalArgumentException: No configs match configSpec
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:760)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:916)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
Run Code Online (Sandbox Code Playgroud)
任何的想法?
小智 43
这实际上是一个更大问题的一部分,我希望通过发布此处,遇到此错误的其他人将阅读此条目.我同样希望,如果我的任何结论都不正确,有人会提出更明确的解释和/或解决方案.
核心问题是OpenGL支持.从2.2开始,Android支持OpenGL ES 2.0,从4.0.3开始,Android模拟器支持OpenGL ES 2.0.使用OpenGL ES 2.0的代码在4.0.3之前不适用于仿真器.[显然,相机在Android 2.2上从ES 1.0切换到2.0]
但那还不是全部!我遇到的Android文档都没有提到,为了支持Open GL ES 2.0仿真,你的盒子的图形卡芯片组和驱动程序也必须支持OpenGL 2.0.因此,如果在AVD上启用GPU仿真但仍然遇到此错误,请执行以下操作:
1)找出显卡上的规格并访问芯片组制造商的网站,以确定芯片组是否与OpenGL 2.0兼容.如果不是,那么你是SOL,必须坚持通过实际的Android设备而不是模拟器进行调试.
2)确定您是否拥有芯片组的最新图形驱动程序.通过Microsoft获得的驱动程序(如果您使用的是Windows)通常不支持OpenGL,因此您需要从制造商处下载最新的驱动程序.
我希望这有帮助.
Nik*_*hil 17
Android模拟器不支持相机,所以不用担心.这种类型的错误来自Android模拟器2.2,我也检查了Android模拟器1.6,但没有得到错误.
我还检查了Android设备上面的代码三星Galaxy Ace工作正常.
谢谢亲爱的.
| 归档时间: |
|
| 查看次数: |
17986 次 |
| 最近记录: |