My phone is switching off unexpectedly and when I switch it on, it boots up to the lock screen and then switch off immediately. This is repeating at different times for different actions and I cant identify a pattern to replicate it. If I keep the phone connected to the charger then this issue doesn't happen. When I remove it from the charger it will switch off when I try to open some app or sometimes when receiving calls or making calls. It also happens when I open the app drawer. I have done a factory reset and also booted to safe mode,but still the issue is there. All these switch offs happened when the phone was not connected to the charger and the battery charge is more the 50%. I am not sure if the phone is showing the correct battery levels. Also I am not sure if any of the google apps is causing this issue. Can someone help me solve this issue?