Can android sdk free your memory before you are done with it?

My app is getting crash reports on google play. I was told that andorid can release your memory on you, is this really true.

I'm getting a nullpointer exception error on the following line

if (butSettings.Intersect(x, y)) I'm assuming butSettings is null. I'm confuse because butsettings is set up on the oncreate. It's member functions are then called on the onUpdate which gets called every .1 of a second.

line if (butSettings.Intersect(x, y)) is in my ontouch event. So I'm assuming butSettings member functions would have gotten called in the onDraw. So why is this turing into a null?? Could android being freeing it?

stack trace from google

java.lang.NullPointerException at com.fairhvaenapps.toddpuzzlefree.cMainView.onTouchEvent(cMainView.java:267) at android.view.View.dispatchTouchEvent(View.java:5588) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1684) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1684) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1684) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2060) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1398) at android.app.Activity.dispatchTouchEvent(Activity.java:2364) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2008) at android.view.View.dispatchPointerEvent( View.java:5768) at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2911) at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2485) at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:852) at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2494) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4514) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) at dalvik.system.NativeStart.main(Native Method)


Android can destroy your activity at any moment, that's why you have to properly do initialization in onCreate and properly dispose of things in onDestroy . However, you will never end up with a NullPointerException because of this; Android will not just simply remove a reference to an object because of this. The exception you're seeing is because of some bug in your code. It has nothing to do with memory.

链接地址: http://www.djcxy.com/p/18354.html

上一篇: 导航抽屉拉出时,tabhost和选项卡一起运行

下一篇: 在完成之前,android sdk能够释放你的内存吗?