android - getSize() giving me errors -


when implement

windowmanager wm = ((windowmanager)context.getsystemservice(context.window_service)); display display = wm.getdefaultdisplay(); m_ndisplaywidth = display.getwidth(); m_ndisplayheight    = display.getheight(); 

i can run fine, when implement getsize runtimeerror

point size = new point(); display.getsize(size); //error right here m_ndisplaywidth = size.x; m_ndisplayheight = size.y; 

logcat:

03-11 01:45:25.865: e/androidruntime(18835): fatal exception: main  03-11 01:45:25.865: e/androidruntime(18835): android.view.inflateexception: binary xml file line #7: error inflating class com.brain.development.gamerun 03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.createview(layoutinflater.java:518) 03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:570) 03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.rinflate(layoutinflater.java:623) 03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.inflate(layoutinflater.java:408) 03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.inflate(layoutinflater.java:320)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.inflate(layoutinflater.java:276)  03-11 01:45:25.865: e/androidruntime(18835):    @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:215)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.app.activity.setcontentview(activity.java:1679)  03-11 01:45:25.865: e/androidruntime(18835):    @ com.brain.development.braindevelopmentactivity$1.onclick(braindevelopmentactivity.java:25) 03-11 01:45:25.865: e/androidruntime(18835):  @ android.view.view.performclick(view.java:2582)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.view$performclick.run(view.java:9252)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.os.handler.handlecallback(handler.java:587)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.os.handler.dispatchmessage(handler.java:92)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.os.looper.loop(looper.java:130) 03-11 01:45:25.865: e/androidruntime(18835):     @ android.app.activitythread.main(activitythread.java:3691)  03-11 01:45:25.865: e/androidruntime(18835):    @ java.lang.reflect.method.invokenative(native method)  03-11 01:45:25.865: e/androidruntime(18835):    @ java.lang.reflect.method.invoke(method.java:507)  03-11 01:45:25.865: e/androidruntime(18835):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:907)  03-11 01:45:25.865: e/androidruntime(18835):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:665)  03-11 01:45:25.865: e/androidruntime(18835):    @ dalvik.system.nativestart.main(native method)  03-11 01:45:25.865: e/androidruntime(18835): caused by: java.lang.reflect.invocationtargetexception  03-11 01:45:25.865: e/androidruntime(18835):    @ java.lang.reflect.constructor.constructnative(native method)  03-11 01:45:25.865: e/androidruntime(18835):    @ java.lang.reflect.constructor.newinstance(constructor.java:415)  03-11 01:45:25.865: e/androidruntime(18835):    @ android.view.layoutinflater.createview(layoutinflater.java:505)  03-11 01:45:25.865: e/androidruntime(18835):    ... 19 more  03-11 01:45:25.865: e/androidruntime(18835): caused by: java.lang.nosuchmethoderror: android.view.display.getsize  03-11 01:45:25.865: e/androidruntime(18835):    @ com.brain.development.gamerun$gamethread.<init>(gamerun.java:46)  03-11 01:45:25.865: e/androidruntime(18835):    @ com.brain.development.gamerun.<init>(gamerun.java:97)  03-11 01:45:25.865: e/androidruntime(18835):    ... 22 more 

this supports both older , newer devices:

private static point getdisplaysize(final display display) {     final point point = new point();     try {         display.getsize(point);     } catch (java.lang.nosuchmethoderror ignore) { // older device         point.x = display.getwidth();         point.y = display.getheight();     }     return point; } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -