我想捕獲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