I’ve programmed an app which have Main activity, Service and Broadcast receiver. The app, works until i’m trying to kill it with app called memory booster. Then it force closes and my logcat throws 2 NULLPOINTEREXCEPTIONS. On my textview (declared in mainactivity and passed to broadcast receiver ), and ConnectiviyManager ( declared in main activity also, but using in Broadcast receiver ).
01-24 16:25:06.790: E/AndroidRuntime(4820): java.lang.RuntimeException: Error receiving broadcast Intent { act=ACTION_PERFORMED (has extras) } in app.wifito3g.Broadcast@40628910
01-24 16:25:06.790: E/AndroidRuntime(4820): Caused by: java.lang.NullPointerException
01-24 16:25:06.790: E/AndroidRuntime(4820): at app.wifito3g.Broadcast.onReceive(Broadcast.java:122)
Can anyone explains me why ?
Thanks!
EDIT: Detailed stacktrace

and line 122 is:
wifi_state = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
If i comment out line 121, i get NULLPOINTEREXCEPTION ON NEXT LINE which is:
wifi_check.setTextColor(Color.BLACK);
Ok i figured out what was wrong. Here is the solution.
When task manager or whatever app, kills my app it force closes. Thats because from 2.2 Android version you cannot FULLY kill app with other app for that purpose. Android just wont allow that.
When task manager or whatever app “kills” my app, and this app has a running services, an android OS, wants them to run again, so it starts running services again.
Because activity is DEAD and there i instantiated my objects they cannot be used in service again. Some objects MUST be instantiated in service class which i made. ( so they are not null )
Sorry for my bad english .. hope you understand what i tried to say 🙂