title: How to reduce load on main thread?
body: <p>I am pretty new at Android development. I am developing an app which is running slow on opening and the logcat is showing "skipped 55 frames. Too much load on UI thread."I have just heard about async and threading. How can I identify the part in my code that is putting heavy load on main UI. And if you can suggest a way not emphasizing over threading and async tasks.Here what it is doing
  `</p>
  
  <pre><code>package com.pratham.cricket1;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.RadioGroup;
  import android.widget.Spinner;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.Random;
  
  public class MatchPresetsActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
      int a,b,balls;
      Spinner spinner;
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
          switch(adapterView.getSelectedItemPosition()){
              case 0:
                  a=0;
                  break;
              case 1:
                  a=1;
                  break;
          }
  
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  
      }
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.match_presets);
          a=0;
          b=0;
  
          spinner = (Spinner) findViewById(R.id.spinner);
  
          // Create an ArrayAdapter using the string array and a default spinner layout
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
                  R.array.planets_array, android.R.layout.simple_spinner_item);
  // Specify the layout to use when the list of choices appears
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  // Apply the adapter to the spinner
          spinner.setAdapter(adapter);
          spinner.setOnItemSelectedListener(this);
          spinner.setVisibility(View.INVISIBLE);
          RadioGroup r1=(RadioGroup)findViewById(R.id.choose);
  
  
          switch(r1.getCheckedRadioButtonId()){
              case R.id.t20:
                  balls=120;
                  break;
              case R.id.t50:
                  balls=300;
                  break;
          }
  
  
  
      }
      public void toss(View view){
          Random rand=new Random();
          int a=rand.nextInt(50);
          if(a&gt;25){
              b=0;
              spinner.setVisibility(View.VISIBLE);
              Toast.makeText(this,"Team A wins the toss",Toast.LENGTH_SHORT).show();
          }else {
              spinner.setVisibility(View.VISIBLE);
              b=1;
              Toast.makeText(this,"Team B wins the toss",Toast.LENGTH_SHORT).show();
          }
  
      }
      public void start(View view){
          Intent i1=new Intent(this,MainActivity.class);
          Bundle bundle=new Bundle();
          bundle.putInt("Balls",balls);
          bundle.putInt("Team won toss",b);
          bundle.putInt("Winning team chose",a);
          i1.putExtras(bundle);
          startActivity(i1);
  
      }
  }
  </code></pre>
  
  <p>`
  Does the next activity initialising slows it down even though it is not displayed.
  This problem is only on Moto g3 and when I try or on opposite phone or works totally fine .</p>