Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : What should I do instead of using a deprecated function(getwidth() )?

I want to use the function activity.getWindowManager().getDefaultDisplay().getwidth() but there is a warning that says this function is deprecated

What should I do ? Should I use this function anyway? or there is some other functions that do the same ?

like image 331
Navid777 Avatar asked Feb 25 '13 12:02

Navid777


1 Answers

Deprecated means that it shouldn't be used, but it's still there for compability reasons.

You should use instead:

Point size = new Point();
activity.getWindowManager().getDefaultDisplay().getSize(size);
int width = size.x;
int height = size.y;
like image 147
Michał Z. Avatar answered Oct 13 '22 18:10

Michał Z.