1

I'm developing an application that requires the functionality allowing the user to browse through the Sd card and select an image of his choice as the background for the application.

This image is assumed to be in the sd card. But the name and location(specific) folder is unknown.

I got the code of getting an image to my background. This is the code but here the filename is known in advance. I want the user to select the file he needs.

I also referred to this code but couldn't link the two of them. Can someone provide me with a solution? Thanks in advance..

Community
  • 1
  • 1
ARK
  • 57
  • 1
  • 8

1 Answers1

0

Before starting the MainActivity, use an another activity in which in onCreate call the ImagePicker Code. After selecting an image, after coming back to onActivityResult, call the mainActivity and pass the Image path with Intents. Then use the as usual code that you have to set it as back ground.

Pavandroid
  • 1,586
  • 2
  • 15
  • 30
  • Thanks pavan.. but can you tell me how can i pass the image to next activity with intent and also how to recieve it? My image is stored in ` Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);` – ARK Mar 29 '12 at 06:14
  • Either You can pass the File path to other Activity and Create Bitmap over there or You can pass the Object directly to other Object. Please check the below link http://pavandroid.blogspot.in/2010/07/customizing-buttons-we-can-customize_1669.html for more info of Sending and Receving Objects and Strings between Activities. – Pavandroid Mar 29 '12 at 07:15