I’m using a timer which needs context.
Now I have the following code :
mContext=context;
mEventID=eventID;
CountDownTimer cdTimer = new CountDownTimer(20000, 1000) {
public void onTick(long millisUntilFinished) {
// Do nothing onTick... Sorry
}
public void onFinish() {
int deletedRows = mContext.getContentResolver().delete()
// ..rest of code
}
};
cdTimer.start();
Is this safe to use , or may I be leaking the context here?
btw. This is in a broadcastreceiver.
You should not pass the Context into the Thread, instead refer to it by it’s parent name.
something like this
So you probably need to call the context by your broadcast receiver’s name eg:
MyReceiver.this.contextassumingcontextis a member of the class.