![](/img/trans.png)
[英]How to send an object from one Android Activity to another using Intents?
[英]How to send an object containing drawable objects from one android activity to another using intents?
將Drawable轉換為Bitmap並將其發送到Another Activity。
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
發送,
intent.putExtra("Bitmap", bitmap);
獲取,
Bitmap bitmap = (Bitmap)this.getIntent().getParcelableExtra("Bitmap");
好吧,你無法真正發送含有意圖的圖像,因為你可以附加為僅限於可Serializable
對象的附加內容。 但是你可以存儲圖像(在內存中使用不同的結構(如HashMaps,使用hashmap將為搜索該圖像提供一些速度優化))並向其他活動發送通知以從hasmap讀取。 您可以將hashmap中圖像的鍵添加為附加到intent的附加項中的字符串。 或者您可以緩存圖像並通過意圖發送它的名稱/路徑:)
希望這可以幫助 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.