0

I get the following message appears in the log.

      12-07 22:25:05.509: I/Choreographer(3788): Skipped 60 frames!  The application may be doing too much work on its main thread.

I'm trying to improve my code line by line. And I will do the heavy works in a separate thread.

I wanted to know the following method except the heavy works? If there? What do I do to improve the code?

I know the work such as downloading a photo or database-related tasks, etc. is part of the heavy workes.

but Do the following method is time consuming?

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main1);

    //other codes
     define();

   }

public void define()
   {
counter_photo=(TextView)findViewById(R.id.text_counter_photo);
counter_audio=(TextView)findViewById(R.id.text_counter_audio);
counter_video=(TextView)findViewById(R.id.text_counter_video);
counter_sum=(TextView)findViewById(R.id.text_counter_sum);
path=getResources().getStringArray(R.array.path);
length_folder=new int[4];
escan=(LinearLayout)findViewById(R.id.linear_escan);
delete=(LinearLayout)findViewById(R.id.linear_delete);
progress1=(ProgressBar)findViewById(R.id.progress1);
push=(LinearLayout)findViewById(R.id.linear_push);
mDrawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout);
home=(ImageView)findViewById(R.id.imag_home);
counter_android=(TextView)findViewById(R.id.text_counter_android);
coustomCircle=(CustomCircle)findViewById(R.id.customCircle1);
TextView item1=(TextView)findViewById(R.id.txt_item1);
 anim_bottomL = AnimationUtils.loadAnimation(this, R.anim.trans_bottom_left);
 scale = AnimationUtils.loadAnimation(this, R.anim.plus);
 anim_bottomR = AnimationUtils.loadAnimation(this, R.anim.trans_bottom_right);
 anim_topL = AnimationUtils.loadAnimation(this, R.anim.trans_up_left);
 anim_topR = AnimationUtils.loadAnimation(this, R.anim.trans_up_right);

 anim_topL.setInterpolator((new AccelerateDecelerateInterpolator()));
 anim_topR.setInterpolator((new AccelerateDecelerateInterpolator()));
 anim_bottomL.setInterpolator((new AccelerateDecelerateInterpolator()));
 anim_bottomR.setInterpolator((new AccelerateDecelerateInterpolator()));
 if(tel_or_mobo==0)
 {
     item1.setText(getResources().getString(R.string.s_item1_1));
     item1.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.icon_item1, 0);
 }else
 {
     item1.setText(getResources().getString(R.string.s_item1));
     item1.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_launcher, 0);
 }
 anim_topL.setFillAfter(true);
  anim_topR.setFillAfter(true);
  anim_bottomL.setFillAfter(true);
  anim_bottomR.setFillAfter(true);



}
madam
  • 119
  • 8
  • The best way to find out if this method is time-consuming is to measure the execution time yourself! There's an example here: http://stackoverflow.com/questions/180158/how-do-i-time-a-methods-execution-in-java – ehehhh Dec 07 '15 at 21:06
  • I have read the above link.I want to know the methods define() is heavy work? – madam Dec 07 '15 at 21:06
  • 1
    Use Traceview (or Android Studio's equivalent) to determine where you are spending your time. – CommonsWare Dec 07 '15 at 21:08
  • I want to know all the variables defined in the main thread is the right thing? – madam Dec 07 '15 at 21:14

0 Answers0