android - QuickAction by Lorensius -
i'm attempting removed deprecated code getwidth();
code before going production. i've tried few of ways mentioned here @ stack other classes cannot seem work this. know can here?
public class quickaction extends popupwindows implements ondismisslistener { ... public void show (view anchor) { int screenwidth = mwindowmanager.getdefaultdisplay().getwidth(); ... }
i not sure have tried far, use this:
final int version = android.os.build.version.sdk_int; display display = mwindowmanager.getdefaultdisplay(); int screenwidth; if (version >= 13) { point size = new point(); display.getsize(size); screenwidth = size.x; } else { screenwidth = display.getwidth(); }
like javadoc says method display.getwidth()
deprecated in api level 13 should use display.getsize(point)
instead.
in case don't "magic" numbers, instead of 13 can use android.os.build.version_codes.honeycomb_mr2
.
Comments
Post a Comment