To be short...I have a widget, you can see the important part below
public class ExampleWidget extends AppWidgetProvider {
private PhoneStateListener listener;
private TelephonyManager telephonyManager;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
listener = new PhoneStateListener() {
@Override
public void onDataConnectionStateChanged(int state) {
// removed the code
}
};
telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(listener,
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
}
@Override
public void onDisabled(Context context) {
telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
super.onDisabled(context);
}
}
and I am receiving nullpointer exception at telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
when I am removing the widget from the main screen.
What am I missing?