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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -