Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android正在将值传递给另一个活动,但无法读取_Android_Android Activity - Fatal编程技术网

android正在将值传递给另一个活动,但无法读取

android正在将值传递给另一个活动,但无法读取,android,android-activity,Android,Android Activity,我试图将值传递给新活动,但无法从新活动中读取值 这是我的密码 Intent myIntent = new Intent(Photo2Activity.this, MainActivity.class); myIntent.putExtra("image1", image1); myIntent.putExtra("image2", image2); myIntent.putExtra("image3", image3); myIntent.putExtra("konteyner_no", _

我试图将值传递给新活动,但无法从新活动中读取值

这是我的密码

Intent myIntent = new Intent(Photo2Activity.this, MainActivity.class);

myIntent.putExtra("image1", image1);
myIntent.putExtra("image2", image2);
myIntent.putExtra("image3", image3);

myIntent.putExtra("konteyner_no", _txt_konteyner_id.getText().toString());
myIntent.putExtra("mahalle", _txt_mahalle.getText().toString());
myIntent.putExtra("sokak", _txt_sokak.getText().toString());

myIntent.putExtra("konteyner_temizmi", _check_konteyner_temizmi.isChecked());
myIntent.putExtra("yaninda_cop_varmi", _check_yaninda_cop_varmi.isChecked());
myIntent.putExtra("aralarinda_cop_varmi", _check_aralarinda_cop_vardi.isChecked());
myIntent.putExtra("zamansiz_cop_varmi", _check_zamansiz_cop_vardi.isChecked());
myIntent.putExtra("cop_obekleri_vardi", _check_cop_obekleri_vardi.isChecked());

myIntent.putExtra("note", _txt_note.getText().toString());

startActivity(myIntent);

如何从新活动(MainActivity)中读取它们?

将位图转换为字节数组:-

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
将字节数组传递到intent:-

Intent intent = new Intent(MainActivity.this, NextActivity.class);
intent.putExtra("picture", byteArray);
startActivity(intent);
从Bundle中获取字节数组并转换为位图图像:-

Bundle extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("picture");
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(bmp);
传递基本类型检查下面的链接


如果要传递其基本类型,请检查此链接。你正在传递图像吗?我有3个位图,我正在发送位图,我需要将这些图像和其他图像传递给Web服务。将其发送到as bytearray是否更好?您可以在活动之间传递位图(标题中的值)。没有提到webservice。答案是在活动之间传递位图。您应该使用http post请求将图像发送到服务器