[英]Passing an image to another activity
我有一個存儲在硬盤上的圖像,想要移動到另一個活動。
在主要活動中,我輸入的路徑如下:
String address = "/ Dir_Imagen / nombre.png";
在輔助活動中,一旦我獲取了目錄,請輸入:
Bitmap icon = BitmapFactory.decodeFile (address);
問題是變量圖標返回null。
有人知道怎么了嗎?
實際上,您可以在實現可打包時將位圖對象從一個活動傳遞到另一個活動:
Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("icon", icon);
然后從第二個活動中,使用以下命令返回位圖:
Bitmap icon = (Bitmap) getIntent().getParcelableExtra("icon");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.