Reputation: 3740
I know the Display
method getWidth()
has been deprecated since API 13. I have the following line of code:
Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int displayWidth = display.getWidth();
What is the alternative for API Level 13 and above?
Upvotes: 1
Views: 2768
Reputation: 384
In case you're not in an activity use
context.getResources().getDisplayMetrics().heightPixels;
context.getResources().getDisplayMetrics().widthPixels;
Upvotes: 2
Reputation: 9678
You are looking for getSize(Point outSize)
(according to official android API documentation )
Hope this helps!
Upvotes: 1