0

当我在模拟器中运行我的应用程序时,它会给出一条 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}

被称为包 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 方法中,我正在调用另一个具有一些计算的类的函数。这是原因..,如果是,我该如何删除它?

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

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

4

2 回答 2

0

这意味着您的主线程不断运行,通过其消息队列泵送消息而不会空闲。如果这是您想要的,则没有什么可修复的。这就是为什么日志消息是警告而不是错误的原因。(更多)和其他来自 google的消息。

观看更多信息

于 2012-05-29T08:31:50.697 回答
0

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

如果您可以发布您的代码和您的 SDK 版本,我可以提供更多帮助。stackoverflow 上还有另一个关于此的线程。HistoryRecord 的活动空闲超时?

于 2012-05-29T08:26:49.137 回答