Can anyone tell me how to call the n number of activities from different pages using sharedPreference?
Asked
Active
Viewed 308 times
1
-
Question is unclear......Modify your questionnnn – Harneet Kaur Jun 18 '12 at 12:35
1 Answers
2
You can save an array in your SharedPreference
. Here's an example for that.
Your array can hold the names of your Activities
. Like:
String activityNames[] = { "Activity1" , "Activity2" , "Activity3" };
Fetch this array from your SharedPreference
, and then start the desired Activity
using:
Class selected = Class.forName("learn.myandroidapp.hr." + activityNames[someIndex]);
Intent selectedIntent = new Intent(CurrentActivity.this,selected);
startActivity(selectedIntent);
I haven't given you the entire code, but the basic idea(which is more than sufficient,I believe). Feel free to enquire for more.

Community
- 1
- 1

Kazekage Gaara
- 14,972
- 14
- 61
- 108