开发者

Multiple instances of the same android widget: Anyway way to have instance specific preferences?

开发者 https://www.devze.com 2022-12-22 12:48 出处:网络
I am creating a simple Android widget with a typical usecase of having many instances of it running at once.

I am creating a simple Android widget with a typical usecase of having many instances of it running at once.

Using the stock preferencesmanager, it seems each instance of the widget shares the same preferences.

Is there any way to not have this happen?

Thanks开发者_JAVA技巧!


You can try overriding getPreferenceManager() in your PreferenceActivity, and return a custom PreferenceManager in which you have overridden getPreferences() to return a different SharedPreferences object for each app widget. I have not tried this, so I am not completely certain it will work. If it does, and you think of it, comment on this answer to let me know!

0

精彩评论

暂无评论...
验证码 换一张
取 消