Reputation: 769
I 'm new about android.I need ContentResolver instance when modifying PhoneWindowManager file.but the PhoneWindowManager doesn't inherit the Context class.I don't know how to obtain ContentResolver in this case .thanks for helping.
Upvotes: 2
Views: 1303
Reputation: 33996
If in some class in which there is no context
then you can create a constructor or a method
which takes the context and then use this context to get ContentResolver instance or to access any context related methods.
Upvotes: 1
Reputation: 24820
PhoneWindowManager has a mContext object initialized so you can get the contentResolver using
mContext.getContentResolver()
Upvotes: 1
Reputation: 1013
Try to make a new class which extends PhoneWindowManager class. Add a new field of type Context in this new class. Make a constructor in which you provide a context:
MyClass( Context cont ){
myContext = cont;
}
Upvotes: 1