0

I implement a notification in the notification area, which can be clicked and go to the Sound Setting preference activity. There's several categories in this page, how can i scroll to a category or a preference item exactly I want? If I do noting and just start the Sound Setting, I can't see the category I want immediately.

Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70

2 Answers2

1

If SettingsActivity is yours custom activity you can

getListView().setSelection(i);

if you mean native android sound settings I think you can't.

To scroll to certain category I think you must to do somethink like this

PreferenceCategory category = (PreferenceCategory)findPreference("you_category_key");
        for (int i = 0; i <  getPreferenceScreen().getRootAdapter().getCount(); i++){
            Object o = getPreferenceScreen().getRootAdapter().getItem(i);
            if (o instanceof PreferenceCategory ){
                if (o.equals(category)){
                    getListView().setSelection(i);
                }
            }
        }

But unfortunately this code has no effect in onCerate and onResume, dont know why. Try to past this code in other palces.

Georgy Gobozov
  • 13,633
  • 8
  • 72
  • 78
  • Thanks. And in android 4.1, how can I locate the category. The selection in the Code "getListView().setSelection(i);" does not include category, right? – user1619301 Aug 23 '12 at 10:38
0

try this out, Hope it should help.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS);
        startActivity(intent);

    }
Sharanabasu Angadi
  • 4,304
  • 8
  • 43
  • 67