You can, but the micro USB connection is not powerful enough to charge the camera faster than it is drained while capturing an image. For 300 sec exposures you should be fine but while capturing movie your battery will eventually run out.
I like to take shots of deep sky. I just bought a Sony a6400 and I want to use long exposures (300 seconds using a tracking platform). Can I connect the supplied cable and use the camera while it is connected? Are there any risk? Normally, I use my Canon camera with a dummy battery for 5 hours, so just need to know if it's necessary to buy a dummy batery for the a6400 too.
i have also just found that if i plug in USB power via the micro usb port, then insert the dummy battery and turn on the camera, the internal battery keeps its charge. i can then unplug the micro usb power and it will work normally. its then fine to swap to a regular battery.
so something about when plugging in a dummy battery by its self sets off the internal battery
i just went through the manual and i understand how it works. regular batteries keep the internal battery charged when swapping. but as soon as i plug in a dummy battery, the internal battery seems to discharge so it loses date and time.
i keep a full battery in my camera every night so i know the internal battery gets charged.