Tuesday, May 3, 2011

[android-developers] Re: Widget-specific Preferences

Kostya,

I've been noodling around thinking about this problem while working on
other features but I'm stumped on one part of it. When the Preference
Activity is launched as a Configuration Activity the intent contains
widget ID. But I can also launch the same Activity if the user touches
the widget so that the user can reconfigure the widget even after it has
been installed. In that situation, how can I know which widget is being
reconfigured? The widget ID is not part of the widget itself so I don't
how I can grab the ID of the specific widget that is being reconfigured.

...Jake

>>>>> "KV" == Kostya Vasilyev <kmansoft@gmail.com> writes:

KV> Well, in that case you already know the widget id for a
KV> particular instance of your configuration activity - it's passed
KV> in as an intent extra.

KV> 25.04.2011 1:21 пользователь "Jake Colman" <colman@ppllc.com> написал:
>>>>>>> "KV" == Kostya Vasilyev <kmansoft@gmail.com> writes:
>>
KV> 24.04.2011 19:35, Jake Colman пишет:
>>
>> >> If I use an onClickListener() and on
>> >> SharedPreferenceChangeListener() to detect specific preference
>> >> clicks or changes to a preference, I can parse out the widget
>> >> ID from the key so that I know which specific widget has been
>> >> effected. I can then make sure that I update just that specific
>> >> widget accordingly. Can you think of a better way to do that?
>>
KV> Umm... Sounds like you also want to present options for multiple
KV> widgets at the same time within a single preference activity?
>>
KV> If so, I would not use the activity as the event listener.
>>
KV> I'd create a class that encapsulates the complete set of
KV> preferences for one widget instance, serves as the event listener
KV> for the involved Preference objects, and knows its associated
KV> widget Id value. The activity would instantiate these objects as
KV> needed, one for each widget Id.
>>
KV> I'd also use onPreferenceChange rather that
KV> onSharedPreferenceChanged, because the former uses a Preference
KV> reference you can switch on, without parsing preference keys.
>>
>> Actually, no. :-)
>>
>> I want to, for example, allow instance #1 to have a different label than
>> instance #2. If I continue to use my single Preference Activity which
>> has one listener for all widgets, it will need to know which widget's
>> key has been changed so that it can update that instance. Hmmmmm.
>> Unless I just update all instances all the time when any one instance's
>> preference is changed...
>>
>>
>> --
>> Jake Colman -- Android Tinkerer
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscribe@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en

KV> --
KV> You received this message because you are subscribed to the Google
KV> Groups "Android Developers" group.
KV> To post to this group, send email to android-developers@googlegroups.com
KV> To unsubscribe from this group, send email to
KV> android-developers+unsubscribe@googlegroups.com
KV> For more options, visit this group at
KV> http://groups.google.com/group/android-developers?hl=en

--
Jake Colman -- Android Tinkerer

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment