You can not accurately guess that how much time is remaining for battery discharge, because there might be different applications or service consuming battery.
However you can get battery life with help of broadcast receiver by registering a receiver for action Intent.ACTION_BATTERY_CHANGED.
By using the below statement in onReceive() method of BroadcastReceiver with above Intent action, you will get battery level currently available. But you can't estimate the time remaining, because some apps may consume more power.
battery_level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);