0


カメラアクティビティを使用してキャプチャした画像のimagePathをデータベースに保存する方法。また、そのimagePathを取得して、別のアクティビティに表示する必要がありますか?
誰かが私を助けてくれますか?

アップデート:

public class Image_secondPage extends Activity 
{
    public static final int CAMERA_RESULT = 1;
    Button btn1;
    ImageView imageView1;
    private final String tag = getClass().getName();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_secondpage);


        imageView1 = (ImageView)findViewById(R.id.imageView1);
     Button btnNext = (Button)findViewById(R.id.buttonNext);
     btnNext.setOnClickListener(new View.OnClickListener()
    {

        @Override
        public void onClick(View v)
        {
            Intent intent = new Intent(Image_secondPage.this, ImagesPage.class);
            startActivity(intent);

        }
    });


        PackageManager pm = getPackageManager();
        if(pm.hasSystemFeature(PackageManager.FEATURE_CAMERA))
        {
            Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContentProvider.CONTENT_URI);
            startActivityForResult(i, CAMERA_RESULT);
        }
        else
        {
            Toast.makeText(getBaseContext(), "Camera is not available", Toast.LENGTH_LONG).show();
        }   

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        Log.i(tag, "Receive the camera result");
        if(resultCode == RESULT_OK && requestCode == CAMERA_RESULT)
        {
            File out = new File(getFilesDir(), "newImage.jpg");
            if(!out.exists())
            {
                Toast.makeText(getBaseContext(), "Error while capturing image", Toast.LENGTH_LONG).show();
                return;
            }
            Bitmap mBitmap = BitmapFactory.decodeFile(out.getAbsolutePath());
            imageView1.setImageBitmap(mBitmap);
        }
    }



    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        imageView1 = null;
    }

キャプチャしたimagePathを取得し、次のクラスで持っていたimageViewに画像を表示することになっていますが、方法がわかりません。誰かが私を助けることができますか?

4

1 に答える 1

0

これを使ってみてください

bitmap = (Bitmap) data.getExtras().get("data"); 

これによりビットマップ画像が得られ、データベースまたは必要なものに保存できます。
これで問題が解決しない場合はお知らせください。

于 2012-07-18T08:32:08.840 に答える