android - get @hide property via reflection -
i have use follow code localdisplaymetrics .
displaymetrics localdisplaymetrics = new displaymetrics(); ((windowmanager) getsystemservice("window")).getdefaultdisplay() .getmetrics(localdisplaymetrics);
i want localdisplaymetrics.noncompatwidthpixels
.can via reflection?
try this:
displaymetrics localdisplaymetrics = new displaymetrics(); ((windowmanager) getsystemservice(window_service)).getdefaultdisplay().getmetrics(localdisplaymetrics); try { field field = displaymetrics.class.getdeclaredfield("noncompatwidthpixels"); field.setaccessible(true); int value = field.getint(localdisplaymetrics); } catch (nosuchfieldexception e) { e.printstacktrace(); } catch (illegalaccessexception e) { e.printstacktrace(); }
Comments
Post a Comment