Q:

Activity Recreates and blinking

I have FirstRunActivity and MainActivity (launcher). When app opening and if app opened for the first time, i start FirstRunActivity (with clearing activity history).
It's working ok. But when turning on autorotation in device, then opening app with rotated device, screen is blinking. In log i can see that activity is recreates itself in loop.
Log :
3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:00.390    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:00.410    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:00.410    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:00.480    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:00.480    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:00.520    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:00.520    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:00.630    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:00.630    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:00.680    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:00.680    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:00.800    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:00.810    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:00.870    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:00.870    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:00.960    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:00.970    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:00.990    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:00.990    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:01.060    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:01.060    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:01.080    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:01.080    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:01.150    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:01.150    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:01.180    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:01.180    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:01.250    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause
04-17 22:49:01.250    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStop
04-17 22:49:01.280    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onStart
04-17 22:49:01.280    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onResume
04-17 22:49:01.430    3028-3028/tm.mobile.payment D/SazHyzmat﹕ FirstRunActivity onPause

FirstRunActivity.java :
public class FirstRunActivity extends ActionBarActivity {

    @InjectView(R.id.password) EditText passwordView;
    @InjectView(R.id.password_retype) EditText passwordRetypeView;
    @InjectView(R.id.save) View saveButton;

    @Override
    protected void onCreate( Bundle savedInstanceState ) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first_run);
        ButterKnife.inject(this);
    }

    @Override protected void onStart() {
        super.onStart();
        U.l("FirstRunActivity onStart");
    }

    @Override protected void onStop() {
        super.onStart();
        U.l("FirstRunActivity onStop");
    }

    @Override protected void onPause() {
        super.onStart();
        U.l("FirstRunActivity onPause");
    }

    @Override protected void onResume() {
        super.onStart();
        U.l("FirstRunActivity onResume");
    }
}

MainActivity.java :
@Override
    protected void onCreate( Bundle savedInstanceState ) {
        super.onCreate(savedInstanceState);
        settingsManager = SettingsManager.getInstance(this);
        //If app not initialized
        if (! settingsManager.isAppInitialized()) {
            Intent intent = new Intent(this, FirstRunActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            ComponentName cn = intent.getComponent();
            Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
            startActivity(mainIntent);
               finish();
        } else {
            //Other code
        }
}

If i change code that starting first run activity (in MainActivity.java) with just starting activity, activity is not blinking, but when pressing back button it will open MainActivity with white screen. 
Or clearing activity history with other way like here: Clear the entire history stack and start a new activity on Android screen is blinking anyway.
So how can i stop blinking and clearing activity history?
EDIT
After tests i have found that in my other activities, that have no connection with above code, have same problem, blinking. When opening activity with rotated device.

A:

Looking at the documentation for IntentCompat.makeRestartActivityTask, it sounds like it creates an intent that serves to restart your current activity. I recommend removing these two lines:
ComponentName cn = intent.getComponent();
Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);

I've never needed them while changing activities.
Additionally, the call to mContext.finish() can be accomplished with just finish()  and can never be null in that case, most likely the reason that you were seeing the white screen was that mContext was null, so you never successfully finished that activity.

