title: App user force to login first
body: <p>I am beginner in App development and I have ready made source code. 
      Please find below two files, I want to force user to login first then redirect to home page, If I change MainActivity to LoginActivity in IntroActivity file user getting login window but after login not redirect to MainActivity page. Please suggesst where exactly I need to change.</p>
  
  <p>Code are: </p>
  
  <p><strong>File 1 :IntroActivity.java</strong></p>
  
  <pre><code>package com.ristana.bullish.ui.activity;
  
  import android.content.Intent;
  
  import android.content.pm.PackageInfo;
  import android.content.pm.PackageManager;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ProgressBar;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.ristana.bullish.R;
  import com.ristana.bullish.entity.ApiResponse;
  import com.ristana.bullish.manager.PrefManager;
  
  import java.util.Timer;
  import java.util.TimerTask;
  
  import retrofit2.Call;
  import retrofit2.Callback;
  import retrofit2.Response;
  import retrofit2.Retrofit;
  import com.ristana.bullish.api.apiClient;
  import com.ristana.bullish.api.apiRest;
  
  public class IntroActivity extends AppCompatActivity {
      private ProgressBar intro_progress;
      private RelativeLayout activity_intro;
      private PrefManager prf;
      private TextView text_view_app_version;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getSupportActionBar().hide();
          prf= new PrefManager(getApplicationContext());
          initView();
          Timer myTimer = new Timer();
          myTimer.schedule(new TimerTask() {
              @Override
              public void run() {
                  // If you want to modify a view in your Activity
                  IntroActivity.this.runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                          if (prf.getString("LOGGED").contains("TRUE")){
                              checkAccount();
                          }else{
                              Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                              startActivity(intent);
                          }
                      }
                  });
              }
          }, 5000);
      }
      private  void initView(){
          setContentView(R.layout.activity_intro);
          this.intro_progress=(ProgressBar) findViewById(R.id.intro_progress);
          this.activity_intro=(RelativeLayout) findViewById(R.id.activity_intro);
          intro_progress.setVisibility(View.VISIBLE);
          this.text_view_app_version=(TextView) findViewById(R.id.text_view_app_version);
          try {
              PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(),0);
              String version = pInfo.versionName;
  
          } catch (PackageManager.NameNotFoundException e) {
              e.printStackTrace();
          }
      }
      private void checkAccount() {
  
          intro_progress.setVisibility(View.VISIBLE);
          Retrofit retrofit = apiClient.getClient();
          apiRest service = retrofit.create(apiRest.class);
          Call&lt;ApiResponse&gt; call = service.check(prf.getString("ID_USER"),prf.getString("TOKEN_USER"));
          call.enqueue(new Callback&lt;ApiResponse&gt;() {
              @Override
              public void onResponse(Call&lt;ApiResponse&gt; call, Response&lt;ApiResponse&gt; response) {
  
                  if (response.isSuccessful()){
                      if (response.body().getCode()==200){
                          Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                          startActivity(intent);
                      }else if(response.body().getCode()==500){
                          logout();
                          Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                          startActivity(intent);
                      }else {
                          Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                          startActivity(intent);
                      }
                  }else{
                      Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                      startActivity(intent);
                  }
  
              }
              @Override
              public void onFailure(Call&lt;ApiResponse&gt; call, Throwable t) {
                  Intent intent = new Intent(IntroActivity.this,MainActivity.class);
                  startActivity(intent);
                  intro_progress.setVisibility(View.INVISIBLE);
  
              }
          });
  
      }
      public      void logout(){
          PrefManager prf= new PrefManager(getApplicationContext());
          prf.remove("ID_USER");
          prf.remove("SALT_USER");
          prf.remove("TOKEN_USER");
          prf.remove("NAME_USER");
          prf.remove("TYPE_USER");
          prf.remove("USERNAME_USER");
          prf.remove("URL_USER");
          prf.remove("LOGGED");
          Toast.makeText(getApplicationContext(),getString(R.string.message_logout_desibaled),Toast.LENGTH_LONG).show();
      }
      @Override
      public  void onPause(){
          super.onPause();
          finish();
      }
  }
  </code></pre>
  
  <p><strong>File 2: activity_intro.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/activity_intro"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.ristana.bullish.ui.activity.IntroActivity"&gt;
      &lt;ProgressBar
          android:progressDrawable="@drawable/progress_yellow"
          android:indeterminateDrawable="@drawable/progress_yellow"
          style="?android:attr/progressBarStyleLarge"
          android:layout_width="40dp"
          android:layout_height="40dp"
          android:layout_centerInParent="true"
          android:layout_alignParentBottom="true"
          android:layout_marginBottom="10dp"
          android:id="@+id/intro_progress" /&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_marginTop="20dp"
          android:layout_below="@+id/logo_app"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;TextView
              android:layout_gravity="center"
              android:gravity="center"
              android:padding="5dp"
              android:textSize="20dp"
              android:textStyle="bold"
              android:layout_centerInParent="true"
              android:textColor="@color/primary_text"
              android:textAlignment="center"
              android:text=" "
              android:id="@+id/text_view_app_name"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
          &lt;TextView
              android:layout_gravity="center"
              android:gravity="center"
              android:padding="8dp"
              android:textSize="18dp"
              android:layout_centerInParent="true"
              android:textColor="@color/primary_text"
              android:textAlignment="center"
              android:text=" "
              android:id="@+id/text_view_app_version"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
      &lt;ImageView
          android:layout_width="130dp"
          android:layout_height="130dp"
          app:srcCompat="@drawable/logo"
          android:id="@+id/logo_app"
          android:layout_centerInParent="true"
          android:layout_centerHorizontal="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>