Reputation: 3280
I am writing an application which needs to provide a simple preference allowing a user to select an album from their gallery that my application will then load images from.
What I'd like to know is what the simplest method of doing this is, is it possible to do this from a preferences XML file, i.e - can I do something like:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen...>
<Preference...>
<Intent-Filter>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="image/*" />
</Intent-Filter>
</Preference>
</PreferenceScreen>
Or something similar, or is it not possible to receive (and store) a return value via this method? If this is not possible, then what is the simplest way to do this as a custom preference in code.
Please limit any answers to Android 2.2 as this is the minimum version I'm looking to support.
Upvotes: 0
Views: 208
Reputation: 93561
I'm not sure if there's a way to do it via xml, but you can always do it via code. Provide a click listener for the preference, and have it launch the intent via startActivityForResult, then write the result to preferences when it returns.
Remember too that you can always create a custom preference. That ability has been around forever.
Upvotes: 1