【发布时间】:2017-11-11 05:06:39
【问题描述】:
活动 1:我有一个图像视图,其中设置了从相机和画廊拍摄的图像,并且工作正常。在这个 Activity 中有一个右键单击按钮,它会将您重定向到第二个 Activity。
活动2:在这个活动中我有四个选项
- 保存
- 分享
- 通过 Instagram 分享
- 通过 Facebook 分享
活动 3:从上述四个选项中,第三个活动相应地起作用。 现在我不知道如何将第一个活动中拍摄的图像传递给第三个活动。
我的努力:在从相机拍摄的第一张 Activity 图像中:
Intent i=new Intent(Camera.this,SaveVia.class);
i.putExtra("image", thumbnail );
startActivity(i);
在第二个活动中 SaveVia:
Intent intent2 = new Intent(SaveVia.this, Save.class);
Bitmap receiptimage = (Bitmap)getIntent().getExtras().getParcelable("image")
startActivity(intent2);
在名为 Save 的第三个 Activity 中:
Bitmap receiptimage = (Bitmap) getIntent().getExtras().getParcelable("imagepass");
// receipt.setImageBitmap(receiptimage);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
receiptimage.compress(Bitmap.CompressFormat.PNG, 90, bytes);
File storagePath = new File(Environment.getExternalStorageDirectory() + "/PhotoAR/");
storagePath.mkdirs();
File destination = new File(storagePath, Long.toString(System.currentTimeMillis()) + ".jpg");
FileOutputStream fo;
try {
destination.createNewFile();
fo = new FileOutputStream(destination);
fo.write(bytes.toByteArray());
fo.close();
Toast.makeText(Save.this,"No Error",Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(Save.this,"Error Arrived",Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(Save.this,"Error Arrived again",Toast.LENGTH_LONG).show();
【问题讨论】:
-
尝试使用界面...
-
请看这个。 [链接] (stackoverflow.com/questions/4352172/…)。这是您的问题的副本。此外,与链接的问题一样,使用 parcelable 实际传递图像并不是一个好主意。您最好将图像的路径传递给您的第二个和第三个活动,然后使用该路径提取图像。这将是一种更简单的方法。 :)
标签: android android-intent imageview