问题描述:

I need help again.

I'm trying to send a picture of a ctivity to another along with other information . Debugging the application I see that the information is being ransferidas usually , but not the image.

Already tried several codes and none worked , I'm sure I'm doing something wrong but I can not see the error.

Ja tried to send as putExtra inside a Bundle , becoming Byte, but I did not have any success in

Main activity

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.camera);

EditText txtcliente = (EditText)findViewById(R.id.txtcliente);

EditText txtdata = (EditText)findViewById(R.id.txtdata);

EditText txtenderec = (EditText)findViewById(R.id.txtenderec);

EditText txtobs = (EditText)findViewById(R.id.txtobs);

}

//captura de imagem

public void tirarfoto1(View v) {

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

startActivityForResult(intent, 0);

}

@Override

//mostrar de imagem

protected void onActivityResult(int requestcode, int resultcode, Intent data) {

if (data != null) {

Bundle bundle = data.getExtras();

if (bundle != null) {

Bitmap img = (Bitmap) bundle.get("data");

ImageView iv1 = (ImageView) findViewById(R.id.imageView1);

iv1.setImageBitmap(img);

}

}

}

//passagem de dados para proxima view

public void btnenviar(View view) {

EditText cliente = (EditText)findViewById(R.id.txtcliente);

EditText ender = (EditText)findViewById(R.id.txtenderec);

EditText obs =(EditText)findViewById(R.id.txtobs);

EditText data =(EditText)findViewById(R.id.txtdata);

ImageView foto = (ImageView)findViewById(R.id.imageView1);

Intent it = new Intent(this, relatorio.class);

Bundle parametros = new Bundle();

parametros.putString("cliente", cliente.getText().toString());

parametros.putString("ender", ender.getText().toString());

parametros.putString("obs", obs.getText().toString());

parametros.putString("data", data.getText().toString());

parametros.putParcelable("foto", (Parcelable) foto);

it.putExtras(parametros);

it.setClass(this, relatorio.class);

startActivity(it);

}

}

Sub Activity

public class relatorio extends AppCompatActivity implements Serializable {

@Override

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.relatorios);

Intent it = getIntent();

if(it !=null){

Bundle parametros = getIntent( ).getExtras( );

String cliente = parametros.getString("cliente");

String ender = parametros.getString("ender");

String obs = parametros.getString("obs");

String data = parametros.getString("data");

Bitmap bitmap = getIntent().getParcelableExtra("foto");

TextView clienteview = (TextView)findViewById(R.id.txtcliente);

TextView enderview = (TextView)findViewById(R.id.txtenderec);

TextView obsview = (TextView)findViewById(R.id.txtobs);

TextView dataview = (TextView)findViewById(R.id.txtdata);

ImageView imageview = (ImageView)findViewById(R.id.imageView1);

clienteview.setText(cliente);

enderview.setText(ender);

obsview.setText(obs);

dataview.setText(data);

imageview.setImageBitmap(bitmap);

}

}

相关阅读:
Top