In my app when the splash screen gets started I am downloading an image from the URL. I want to use the same image in another activity of my app. Following is my code to download the image
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);
}
How can I get the image as a background source in another activity please help me friends
You can save the image in SDCard and the path can be send to next activity using
and get in the next activity using
from this you can get filepath from previous activity and you can get the image from specific filepath.
You can convert the image into bitmap and and pass it to next activity using Parcelable like
in nextactivity you can get bitmap as