0

こんにちは、

アクティビティ A と B の 2 つのアクティビティがあります。アクティビティ AI には Google マップとボタンがあります。ボタンで写真を撮ることができます。写真を撮った後、編集してタイトルなどを付けることができるアクティビティ B でそれが必要です。

これが私の活動方法です ボタンをクリックして写真を撮ります

private void onTakeFoto() {


    Intent fotoIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    startActivityForResult(fotoIntent, CAMERA_RESULT);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK && requestCode == CAMERA_RESULT) {

        Intent intentB = new Intent(this, B.class);
        startActivityForResult(intentB , CAMERA_RESULT);

    }

}

アクティビティ BI には、imageView と EditText があります。キャプチャした画像をアクティビティ B の imageView に表示したいのですが、どうすればよいですか? 誰かが私にそのヒントを教えてもらえますか?

ありがとう

私の onActivityResult には、次のコードがあります。

String res = null;
        String[] proj = {MediaStore.Images.Media.DATA};
        Cursor cursor =  getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, null, null, null);
        if (cursor.moveToLast()) {
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            res =  cursor.getString(column_index);
                            cursor.close();
                Bitmap bitMap = BitmapFactory.decodeFile(res);
                m_currentImage.setImageBitmap(bitMap);

        }

私が言ったように、キャプチャされたものではなく、他の画像を取得しました。誰かが間違いを教えてもらえますか?

4

4 に答える 4

0

putExtraを介して、 fotoIntentアクティビティの結果を新しいBアクティビティに渡すことができます。

于 2013-05-19T19:17:12.500 に答える
0

1 つの提案は、UI スレッドではなく、他のスレッドで画像のデコードを行ってください。

于 2013-05-19T19:19:44.467 に答える
0

アクティビティ B クラスでカメラを起動して写真を撮り、imageview に写真を設定することができます。この方法を使用します...

@Override
    protected void onActivityResult(int requestCode, int resultCode,
            Intent resultData) {
        super.onActivityResult(requestCode, resultCode, resultData);



        try {

            if ( resultData != null) {

                String[] projection = { MediaStore.Images.Media.DATA };
                Cursor cursor = managedQuery(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        projection, null, null, null);
                int column_index_data = cursor
                        .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                cursor.moveToLast();

                uploadImagePath = cursor.getString(column_index_data);
                bitmapUploadImage = BitmapFactory.decodeFile(uploadImagePath);
                profileImageView.setImageBitmap(bitmapUploadImage);
于 2013-05-19T17:17:11.897 に答える