package org.commcare.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.commcare.dalvik.R;
import org.commcare.utils.StringUtils;

/**
 * Activity that is shown when a user tries to install more than 2 apps at a time, without having
 * either superuser privileges or a multiple apps seat enabled on the device.
 *
 * @author Aliza Stone (astone@dimagi.com), created 6/9/16.
 */
public class MultipleAppsLimitWarningActivity extends CommCareActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.multiple_apps_limit_view);
        TextView mulitpleAppLimitTextView = findViewById(R.id.mulitple_app_limit_textview);
        String text = StringUtils.getStringRobust(this,
                R.string.multiple_apps_limit_message,
                String.valueOf(CommCareSetupActivity.MAX_ALLOWED_APPS));
        mulitpleAppLimitTextView.setText(text);
        boolean installAttemptCameFromAppManager = getIntent()
                .getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER, false);
        setupUI(installAttemptCameFromAppManager);
    }

    private void setupUI(final boolean installAttemptCameFromManager) {
        Button toManagerButton = findViewById(R.id.back_to_manager_button);

        if (installAttemptCameFromManager) {
            toManagerButton.setText(R.string.back_to_manager);
        } else {
            toManagerButton.setText(R.string.go_to_manager);
        }

        toManagerButton.setOnClickListener(v -> onManagerButtonClicked(installAttemptCameFromManager));
    }

    private void onManagerButtonClicked(boolean installAttemptCameFromManager) {
        if (installAttemptCameFromManager) {
            setResult(RESULT_OK);
            finish();
        } else {
            Intent i = new Intent(MultipleAppsLimitWarningActivity.this, AppManagerActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
        }
    }

}

package org.commcare.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.commcare.dalvik.R;
import org.commcare.utils.StringUtils;

/**
 * Activity that is shown when a user tries to install more than 2 apps at a time, without having
 * either superuser privileges or a multiple apps seat enabled on the device.
 *
 * @author Aliza Stone (astone@dimagi.com), created 6/9/16.
 */
public class MultipleAppsLimitWarningActivity extends CommCareActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.multiple_apps_limit_view);
        boolean installAttemptCameFromAppManager = getIntent()
                .getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER, false);
        setupUI(installAttemptCameFromAppManager);
    }

    private void setupUI(final boolean installAttemptCameFromManager) {
        Button toManagerButton = findViewById(R.id.back_to_manager_button);

        if (installAttemptCameFromManager) {
            toManagerButton.setText(R.string.back_to_manager);
        } else {
            toManagerButton.setText(R.string.go_to_manager);
        }

        toManagerButton.setOnClickListener(v -> onManagerButtonClicked(installAttemptCameFromManager));

        TextView mulitpleAppLimitTextView = findViewById(R.id.mulitple_app_limit_textview);
        String text = StringUtils.getStringRobust(this,
                R.string.multiple_apps_limit_message,
                String.valueOf(CommCareSetupActivity.MAX_ALLOWED_APPS));
        mulitpleAppLimitTextView.setText(text);
    }

    private void onManagerButtonClicked(boolean installAttemptCameFromManager) {
        if (installAttemptCameFromManager) {
            setResult(RESULT_OK);
            finish();
        } else {
            Intent i = new Intent(MultipleAppsLimitWarningActivity.this, AppManagerActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
        }
    }

}

Move view inflation logic to setupUI method