I’m trying to call an activity from a Preference item
Ideally I’d like to simply specify an explicit intent in the xml for that Preference item
but my google fu has deserted me and I can only find examples of implicit intents, e.g.
<Preference android:title="@string/prefs_web_page" >
<intent android:action="android.intent.action.VIEW"
android:data="http://www.example.com" />
</Preference>
I have already called my activity elesewhere programatically, e.g.
Intent intent = new Intent(this, FileChooserActivity.class);
but I want to call this direct from the xml
is this possible or am I barking up the wrong tree?
You can do this:
Add this to your Preference XML:
And add this in your Manifest to Activity to be opened from Preferences:
Make sure com.example.test.pref.action is unique!
Note:
If you need to open a Website or any Activity whose Manifest entry you can’t edit, you’ll need to programatically open it from your Activity com.example.test.pref.action with an Intent.