Search code examples
androidpreference

How to call an Activity from a Preference Activity?


I would like to know how I can start an Activity from a Preference Activity.
My Scenario is like :

I have an application which display a set of images in a View. It can be GridView, or a Gallery View or a ListView.(The default view will be GridView)

On Pressing Menu, i ll get a preference Menu where i have List Preference of views (GridView/GalleryView/ListView).

On selecting a Particular View my main Activity's View which displays images should change.
I would like to know how i can implement this?

I thought of calling my main Activity by an intent which will be invoked on clicking a view in the preference Activity.

Is that possible?

Thanks,
Sen


Solution

  • Step #1: Write a PreferenceActivity.

    Step #2: Have your main activity reload the preference in onResume() and update its UI accordingly.

    You do not need to "call an Activity from a Preference Activity?". Your original activity will regain the foreground once the user presses BACK to exit from the PreferenceActivity.