Twilight is a new Android app that tries to fix that to some extent. It is a free application that works fairly simply - it automatically adapts your screen brightness depending on the time of the day and filters blue light on your device after sunset. Then, a red filter kicks in at an intensity varying with the sunset and sunrise times.
If you are interested in the reasons why you can’t sleep after you read for a while on your phone before going to bed, the reason could be Melanopsin. This is a rereceptor sensitive to blue light that restrains Melatonin production. And Melatonin is the hormone that regulates your body’s sleep-wake cycles. Interestingly, not all displays are equal in that regard and some displays like AMOLED ones (most common on high-end Samsung devices) have a noticeable blueish tint.
Have you had those difficulties falling asleep after toying around with your smartphone or tablet?