So, I'm working inside the android framework classes (AOSP). Since I'm technically working on Cyanogenmod, I'm supposed to set the settings for my patch in an app called CMParts, which just throws the strings and ints into the system settings via Settings.System.
Unfortunately,开发者_如何学C down in the framework (non application) code, I don't have access to a Context object (because I'm not inside an Activity or Application) to give to the usual method call to get those settings back out. Passing a null doesn't work.
Anyone know ANY way to get to those settings from framework-level-code? Passing down a context reference isn't really an option down that far...
The thing you wrote where quite close to mean something. Can you be more specific?
I do not know what framework you are using. But I'm guessing that it is something internal for your company.
But generically speaking:
- if you are not aloud to change the code extend it.
- if you need something from the user implementer, force the user to give it to you.
public MyNewFrameWorkClass extends AnotherFrameWorkClass {
private Context context;
// Disallow the user to create an
// instance with out giving you the context
private MyNewFrameWorkClass() {}
public MyNewFrameWorkClass(Context context) {
this.context = context;
}
}
精彩评论