Using the following code:
public class Panel extends SurfaceView {
// ......
// in one of the methods I want to call
Display display = getWindowManager().getDefaultDisplay();
// ......
}
The problem is with the getWindowManager() method, I guess this method can be called only in activity, but I am not in the activity I am in my custom method called panel. How can I get the DisplayMetrics in my custom component ?
To get the display metrics you have to do this.
Then you can do this.
And have access to it in your custom view.