Yes, your application can get that message if you implement a BroadcastReceiver class like the one below.
public class ShutdownReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
//Insert your code here
}
}
and do't forget to add the following in your manifest file.
<uses-permission android:name="android.permission.DEVICE_POWER" />
and this:
<receiver android:name=".ShutdownReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
</receiver>
You can also do the same for ACTION_BATTERY_LOW.