如何在下一个活动中将两个路径传递到一个图像视图

时间:2015-01-13 11:19:42

标签: android

我在第一个活动中有两个活动我捕获图像并将预览发送到另一个活动,我有一个图库按钮,通过它将图像预览发送到图像视图到下一个活动。所以如何编码设置两个路径图像在一个图像视图中。请帮助我

我的第一项活动:

  PictureCallback  myPictureCallback_JPG = new PictureCallback() {
  public void onPictureTaken(byte[] data, Camera camera) {
  Intent i = new Intent(context, PassActivity.class);
    // String value = "hello";
    // i.putExtra("camera", value);
   Bundle bundle = new Bundle();
    bundle.putByteArray("photo", data);
    i.putExtras(bundle);
 //   startActivity(i);
   // Toast.makeText(CodeActivity.this, "Error Occured", Toast.LENGTH_SHORT).show();
   // setResult(0);
startActivityForResult(i,CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}
};

public void sendImage(){

    intent = new Intent(context,PassActivity.class);
    extras = new Bundle();
    //image = img.getDrawingCache();

    //extras.putParcelable("imagebitmap", picturePath);
    extras.putCharSequence("path",pictureFile);
    intent.putExtras(extras);
    startActivity(intent);
    //startActivityForResult(intent, 1);
}

我的第二项活动:

public void onActivityResult(int requestCode, int resultCode, Intent datas) {



     super.onActivityResult(requestCode, resultCode, datas);

     if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {

        //  previewCapturedImage();
  //   }

          //Toast.makeText(PassActivity.this, "Error Occured", Toast.LENGTH_SHORT).show();
//} 

         Bundle extras = getIntent().getExtras();
         byte[] photo = new byte [2048];
        photo = extras.getByteArray("photo");
        Bitmap bmp = BitmapFactory.decodeByteArray(photo , 0, photo .length);
        imgss.setImageBitmap(bmp);*/



        }

        if (requestCode == CAMERA_CAPTURE_VIDEO_REQUEST_CODE)



        {

            imgss.setVisibility(View.GONE);

            imgsec.setVisibility(View.VISIBLE);

            extras = getIntent().getExtras();
            String path =  extras.get("path").toString();

            Log.i("VALUE",path);
            imgsec.setImageBitmap(BitmapFactory.decodeFile(path));

        }

    }


        /*private void previewCapturedImage() {
            try {
                // hide video preview

                // imgsec.setVisibility(View.GONE);

            //  imgss.setVisibility(View.VISIBLE);

                Bundle extras = getIntent().getExtras();
                 byte[] data = new byte [2048];
                data = extras.getByteArray("photo");
                 final Bitmap bmp = BitmapFactory.decodeByteArray(data , 0, data .length);
                 imgss.setRotation(90);
                imgss.setImageBitmap(bmp);  

            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }

0 个答案:

没有答案