我想捕获Android上的图像并将其显示在图像视图上; 当活动开始时调用的捕获意图和图像视图处于调用捕获的相同活动意图 当我运行应用程序相机捕获图像TWICE然后在图像视图中显示图像?有什么想法为什么?我该如何解决它?在Android上捕获图像
> Activity.java
public class View extends Activity{
ImageView imgview;
Bitmap Bmp;
final static int cameraData = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
imgview = (ImageView) findViewById(R.id.imgview);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bmp = (Bitmap) extras.get("data");
imgview.setImageBitmap(Bmp); }
}}
> camera.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/imgview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Image view"
android:src="@drawable/ic_launcher"
/>
</FrameLayout>
谢谢..我会试试这个 – QAIS