I am working on an app where I am drawing my custom lockscreen (An Activity) over the system's default lock.
Everything is working perfectly fine except one thing, I am using a reciever and whenever there is an incoming call, that reciever gets called and from inside that reciever I am closing the activity.
Note : This is happening only in case of OnePlus device, on any other device it's working perfectly.
private class CallStateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
OverlayActivity overlayActivity = new OverlayActivity();
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// System.out.println("RINGING");
overlayActivity.finish();
// System.out.println("Activity has been closed!!");
break;
}
}
}
Both the lines before and after the code where I am closing the activity is working completely fine, but the activity is not getting closed.
And if you are creating Activity Object its not working at all you needs and Actual Activity Object or Context of Activity to close it.