开发者

Access Settings.System from framework/base code

开发者 https://www.devze.com 2023-01-22 02:13 出处:网络
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

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:

  1. if you are not aloud to change the code extend it.
  2. 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;
    }

}
0

精彩评论

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

关注公众号