Android“跳过31帧!应用程序可能在其主线程上做了太多工作。”

时间:2014-07-22 07:13:26

标签: android multithreading android-listview android-asynctask

我用来调用Async类。我正面临着logcat中的一个问题,显示07-22 12:31:42.657:I / Choreographer(29254):跳过31帧!应用程序可能在其主线程上做了太多工作。这个消息有时候也很粗鲁。我不明白为什么这会显示这条消息

我的代码是

 class LoadSubmitteddoinback extends AsyncTask<URL, Integer, Long>
     {
        MyProgressDialog dialog;JSONObject jobject=null;JSONArray jarraysubmit=null;
        String jsonresult="";
        int strat;
        public LoadSubmittedbloopsdoinback(int strat) {
            super();
            this.strat = strat;
        }

      protected void onPreExecute() 
      { 
          if(boolforprogressdialogmyfeed==true){

              dialog=MyProgressDialog.show(getActivity(), null,null);
              dialog.getWindow().setGravity(Gravity.CENTER); 
              footerView.setVisibility(View.GONE);
          }else{


          loading=true;
          footerView.setVisibility(View.VISIBLE);
//        listfortestmyfeed.addFooterView(footerView);
          }


      }
      @Override
      protected Long doInBackground(URL... arg0) {

    try {



       jsonresult= UrltoValue.getValuefromUrl(DataUrls.submittedsurl+"userid="+userid+"&category="+category+"&start="+strat+"&userid2="+quickuserid);
       Log.e("url is. submitted .load.", DataUrls.submittedsurl+"userid="+userid+"&category="+category+"&start="+strat+"&userid2="+quickuserid);
       jobject = new JSONObject(jsonresult);
          jarraysubmit = jobject.getJSONArray("urls");

          if(jarraysubmit.length()!=0){
                 for(int i=0;i<jarraysubmit.length();i++){

//                   JSONObject jobject= jarray.getJSONObject(i);
                     JSONObject jobject1= jarraysubmit.getJSONObject(i);
                      Bloop bloop= new Bloop();
                      bloop.setBloopid(jobject1.getString("id"));
                      bloop.setUserid(jobject1.getString("userid"));
                      bloop.setTitle(jobject1.getString("title"));
                      bloop.setDescription(jobject1.getString("description"));
                      bloop.setThumb(jobject1.getString("thumb"));

                      bloop.setKeywords(jobject1.getString("keywords"));

                      bloop.setAuthorPic(jobject1.getString("authorpic"));
                      bloop.setViewscount(jobject1.getString("Viewscount"));
                      bloop.setCommentscount(jobject1.getString("commentscount"));
                      try{
                          bloop.setUsercommentstatus(jobject1.getString("usercommentstatus"));
                          bloop.setPublicvalue(jobject1.getString("Public"));
                           bloop.setNsfw(jobject1.getString("NSFW"));}catch(Exception e){e.printStackTrace();}


                      bloops.add(bloop);

                     getActivity(). runOnUiThread(new Runnable() {
                             @Override
                             public void run() {

                                 myfeedAdapter.notifyDataSetChanged();
                                 Utility.setListViewHeightBasedOnChildren(listfortestmyfeed);
                            }
                        });



//                   
                 }

    }else{
        listfortestmyfeed.removeFooterView(footerView);
        listfortestmyfeed.setOnScrollListener(null);
    }

         loading=false;

  }  catch (Exception e1) {
            e1.printStackTrace();

       }


       return null;
      }

      @SuppressLint("NewApi")
      protected void onPostExecute(Long result) {
         try{

              if(boolforprogressdialogmyfeed==true){
                  dialog.dismiss();
                  boolforprogressdialogmyfeed=false;
              }


          }catch(Exception e){e.printStackTrace();}

          }

以上是我的异步课。我没有发现错误,请指导我错误的地方。感谢所有

0 个答案:

没有答案