在我的应用程序中,当启动画面启动时,我正在从 URL 下载图像。我想在我的应用程序的另一个活动中使用相同的图像。以下是我下载图像的代码
public void DownloadImage(String fileName)
{
try
{
URL url = new URL(main.BannerImage); //you can write here any link
File file = new File(fileName);
Log.e("file ",""+file);
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1)
{
baf.append((byte) current);
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(baf.toByteArray());
fos.close();
}
catch (IOException e)
{
Log.e("Error: ","" + e);
}
如何在另一个活动中将图像作为背景源请帮助我的朋友