So I’m making a wallpaper and I want the user to select a folder. So I
have a button in the preferences that launches an intent to open an
image, but what I want is actually just a directory (I guess in the
worst case i can strip the filename from the end). So that’s my first
problem: what’s the best way to select a folder only?
The second problem is how do I get notified of when the intent is
complete?
public class FilePreference extends DialogPreference implements
View.OnClickListener
{
public void onClick(View v)
{
// open up a gallery/file browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
getContext().startActivity(Intent.createChooser(intent, "Select Folder"));
}
Okay that helped a bit, I managed to work out my wallpaper service was actually an activity. SO then I had to find my preference by name and add a pointer to it so the preference could use startActivityForResult and onActivityResult