I have a service listening to some events from server. A service has START_STICKY flag that makes him restart when it's killed by OS. When service receive an event i have two scenarios. First, if activity isn't killed i need to send result to local broadcast receiver and update UI. Second, if it's killed by OS i want to recreate it and send data in bundle.
But i don't know how to recognize that android killed my activity. onDestroy activity event doesn't come in this situation.
    @Override
    public void onComplete(CurrentOrdersResponse response) {
        if (response == null) {
            return;
        }
        boolean isActivityDestroyed = mPreferences.getBoolean(MainActivity.IS_MAIN_ACTIVITY_DESTROYED_PREF_KEY, false);
        if (!isActivityDestroyed)
            sendResult(response.getResJSONStr(), CURRENT_ORDERS_ACTION);
        else {
            Intent intent = new Intent(this, MainActivity.class);
            intent.setAction(Intent.ACTION_VIEW);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtras(extras);
            startActivity(intent);
        }
        int resCode = response.getResCode();
        Log.i(LOG_TAG, "Service resCode" + " " + resCode);
    }
 
    