android中的启动时间错误

时间:2012-05-29 08:20:38

标签: android

当我在模拟器中运行我的应用程序时,它会发送一条logcat消息为..

05-29 13:45:06.941: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
05-29 13:45:07.152: W/ActivityManager(59): Activity idle timeout for HistoryRecord{45163410 com.integrated.mpr/.Progress}
05-29 13:45:07.241: D/dalvikvm(5422): GC_FOR_MALLOC freed 43964 objects / 1967584 bytes in 138ms
05-29 13:45:08.401: D/dalvikvm(5422): GC_FOR_MALLOC freed 73 objects / 536016 bytes in 65ms
05-29 13:45:09.631: W/ActivityManager(59): Activity idle timeout for HistoryRecord{450e8e38 com.integrated.mpr/.SensitiveList}

正在调用的函数     package com.integrated.mpr;

import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.stat.correlation.Covariance;
import org.apache.commons.math.stat.correlation.PearsonsCorrelation;
import org.apache.commons.math.util.FastMath;

import android.util.Log;

public class Logic {

    int n = Choose.n;
    double final_matrix[][] = new double[n][5];
    double swap =0;

    double weightage_matrix[] = {0,0,0,0,0,0,0,0,0,0,0};
    double sorted_weightage[] = {0,0,0,0,0,0,0,0,0,0};
    String  display[] = new String[n]; 

    double input_matrix[][] = new double[22050][n];
    double[] peak_matrix = new double[n];
    double[] sd_matrix = new double[n];
    double[] rms_matrix = new double[n];
    double[] cf_matrix = new double[n];
    double[] mean_matrix = new double[n];
    int[] sensitive_positions = new int[n];
    double[] new_sensitive = new double[n];
    int[] sortsensi = new int[n];


    public String[] finaldata(){



        for(int i=0;i<n;i++){
            peak_matrix[i] = Choose.timedata[i*5+0];
            sd_matrix[i] = Choose.timedata[i*5+1];
            rms_matrix[i] = Choose.timedata[i*5+2];
            cf_matrix[i] = Choose.timedata[i*5+3];
            mean_matrix[i] = Choose.timedata[i*5+4];
        }

        // Arrays sorted in asecnding order
        java.util.Arrays.sort(peak_matrix);
        java.util.Arrays.sort(sd_matrix);
        java.util.Arrays.sort(rms_matrix);
        java.util.Arrays.sort(mean_matrix);
        java.util.Arrays.sort(cf_matrix);



    for(int i = 0;i<n;i++){
        final_matrix[i][0]= peak_matrix[i];
        final_matrix[i][1]= sd_matrix[i];
        final_matrix[i][2]= rms_matrix[i];
        final_matrix[i][3]= cf_matrix[i];
        final_matrix[i][4]= mean_matrix[i];
    }
    Log.d("final matrix", "final matrix 0 0" +final_matrix[0][0]);
    Log.d("final matrix", "final matrix 1 0" +final_matrix[1][0]);
    Log.d("final matrix", "final matrix 2 0" +final_matrix[2][0]);

    Log.d("final matrix", "final matrix 3 0" +final_matrix[3][0]);
    Log.d("final matrix", "final matrix 4 0" +final_matrix[4][0]);

    //final sorted matrix obtained
    for(int i =0;i<n;i++){
            for(int j=0;j<5;j++){
                if(final_matrix[i][j]== Page1.timedata1[j]){
                    weightage_matrix[0] = weightage_matrix[0]+i+1;
                }
                else if (final_matrix[i][j]== Page2.timedata2[j]){
                    weightage_matrix[1] = weightage_matrix[1]+i+1;
                }
                else if (final_matrix[i][j]== Page3.timedata3[j]){
                    weightage_matrix[2] = weightage_matrix[2]+i+1;
                }
                else if (final_matrix[i][j]== Page4.timedata4[j]){
                    weightage_matrix[3] = weightage_matrix[3]+i+1;
                }

                else{
                    weightage_matrix[4] = weightage_matrix[4]+i+1;
                }
        }
    }
    //copying the values into sorted matrix;


    for(int i=0;i<n;i++){
        sorted_weightage[i] = weightage_matrix[i];
    }

    //sorting weighatge matrix in descending order

        for (int i = 0;i<n; i++ )
           {
              for ( int j = 0 ; j < n-i-1 ; j++ )
              {
                  if ( sorted_weightage[j] <sorted_weightage[j+1] ) {
                        swap = sorted_weightage[j];
                        sorted_weightage[j] = sorted_weightage[j+1];
                        sorted_weightage[j+1] = swap;
                  }
              }

           }

    //  String[] display= new String [n];
        /*
        Log.d("", "weightage matrix0 " +weightage_matrix[0]);
        Log.d("", "weightage matrix0 " +weightage_matrix[1]);
        Log.d("", "weightage matrix0 " +weightage_matrix[2]);
        Log.d("", "weightage matrix0 " +weightage_matrix[3]);
        Log.d("", "weightage matrix0 " +weightage_matrix[4]);

        for(int i =0;i<n;i++){
            Log.d("posnames", new Choose().posnames[i]);
        }
        */
    for(int i =0;i<n;i++){
        double temp = sorted_weightage[i];
        for(int j =0;j<n;j++){
            if(temp==weightage_matrix[j]){
                sensitive_positions[i]=j+1;
            }
        }
    }
    //IT IS RUNNING UPTO THIS POINT AND NOW IT GIVES THE LOGCAT MESSAGE OF LAUNCHTIME



    //now for correaltion


    // genearting the input matrix for correaltion


    for(int i=0;i<n;i++){
        for(int j=0;j<22050;j++){
            input_matrix[j][i] =  new Choose().rawdata[i*22050+j];
        }
    }

    // now generating correlation matrix of N x n by using pearson correaltion


    RealMatrix pcorrdata = new PearsonsCorrelation().computeCorrelationMatrix(input_matrix);


    Log.d("checkng correlation mtrix", "yup");

    for(int i =0;i<n;i++){
        for(int j =0;j<n;j++){

            if(pcorrdata.getEntry(i, j)<0){
                pcorrdata.setEntry(i, j, pcorrdata.getEntry(i, j)*-1);
            }
            Log.d(" value", ""+pcorrdata.getEntry(i, j));
        }
    }

    for(int i =0;i<n;i++){
        Log.d("sensitive osition before correlation", ""+sensitive_positions[i]);
    }



    int[] perm_sensitive = sensitive_positions;


    if((pcorrdata.getEntry(perm_sensitive[0]-1, perm_sensitive[1]-1))>0.5){
        sensitive_positions = append(perm_sensitive[1],sensitive_positions);
    }


    for(int i = 0;i<n;i++){
        for(int j =0;j<n;j++){
            if(i==sensitive_positions[0]-1){
                if((j==sensitive_positions[1]-1)){
                    if(pcorrdata.getEntry(i, j)>0.5){
                        sensitive_positions = append(j,sensitive_positions);
                        }
                    }
                }
            }
        }




    if((pcorrdata.getEntry(perm_sensitive[0]-1, perm_sensitive[2]-1))>0.5){
        sensitive_positions = append(perm_sensitive[2],sensitive_positions);
    }





    if((pcorrdata.getEntry(perm_sensitive[0]-1, perm_sensitive[3]-1))>0.5){
        sensitive_positions = append(perm_sensitive[3],sensitive_positions);
    }




    perm_sensitive = sensitive_positions;

    if((pcorrdata.getEntry(perm_sensitive[1]-1, perm_sensitive[2]-1))>0.5){
        sensitive_positions = append(perm_sensitive[2],sensitive_positions);
    }



    if((pcorrdata.getEntry(perm_sensitive[1]-1, perm_sensitive[3]-1))>0.5){
        sensitive_positions = append(perm_sensitive[3],sensitive_positions);
    }




    perm_sensitive = sensitive_positions;


    if((pcorrdata.getEntry(perm_sensitive[2]-1, perm_sensitive[3]-1))>0.5){
        sensitive_positions = append(perm_sensitive[3],sensitive_positions);
    }

    for(int i =0;i<n;i++){
        Log.d("values aft 6th exchange","" +sensitive_positions[i]);
    }

    perm_sensitive = sensitive_positions;

    Log.d("checkng vales", "after correlation");

    for(int i =0;i<n;i++){
        Log.d("values",""+perm_sensitive[i]);
    }


    for(int i =0;i<n;i++){
        display[i] = new Choose().posnames[perm_sensitive[i]-1];
    }

    return display;

    }


    private int[] append(int j, int[] sensitive_positions) {
        // TODO Auto-generated method stub

        int[] sort_sensitive = new int[n];
        int z = 0;
        for(int i =0;i<n;i++){
            if(sensitive_positions[i]!=j){
                sort_sensitive[z]=sensitive_positions[i];
                z = z+1;
            }
        }
        sort_sensitive[n-1] = j;
        return sort_sensitive;
    }







}

实际上在下一个活动的oncreate方法中,我调用另一个具有一些计算的类的函数。这是原因..如果是的话,我该如何删除它?

但仍然在空白屏幕后,下一个活动会打开..

但是我尝试在手机中运行它,它强行关闭。我怎么能删除这个..请帮帮忙?

2 个答案:

答案 0 :(得分:0)

此错误表示您的活动需要很长时间才能启动。如果您在UI线程上进行大量处理,Android会杀死您的应用程序。您应该将AsyncTask用于任何处理密集型的东西。

如果您可以发布代码和SDK版本,我可以提供更多帮助。 stackoverflow上还有另一个关于此的线程。 Activity idle timeout for HistoryRecord?

答案 1 :(得分:0)

这意味着您的主线程不断运行,通过其消息队列传送消息,而不会空闲。如果这是你想要的,没有什么可以解决的。这就是为什么日志消息是警告,而不是错误。(More)和其他来自Google groups

观看更多info