2

我在 logcat 中采用以下内容:

Uncaught handler: thread main exiting due to uncaught exception
05-22 20:16:08.005: W/System.err(13637): java.io.FileNotFoundException: /data/logcat_0.txt (Permission denied)
05-22 20:16:08.005: E/AndroidRuntime(13637): FATAL EXCEPTION: main
05-22 20:16:08.005: E/AndroidRuntime(13637): java.util.concurrent.RejectedExecutionException: pool=128/128, queue=10/10
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1961)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1315)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.execute(AsyncTask.java:394)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.AdController.loadIcon(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.s.onAdOptin(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.AdOptinRequest.onPostExecute(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.finish(AsyncTask.java:417)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.Looper.loop(Looper.java:130)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.app.ActivityThread.main(ActivityThread.java:3683)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.lang.reflect.Method.invokeNative(Native Method)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.lang.reflect.Method.invoke(Method.java:507)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at dalvik.system.NativeStart.main(Native Method)
05-22 20:16:08.045: W/System.err(13637): java.io.FileNotFoundException: /data/plog.log (Permission denied)

我在活动中使用 asynctask(如果这很重要,从我上面看到的内容),但即使我不执行 asynctask,我也会收到错误消息。

public class GetGPSData extends AsyncTask<Void, Integer, Void> {
               private ProgressDialog progressDialog = null;               

               @Override
               protected void onPreExecute() {
                  super.onPreExecute();                          

                   progressDialog = new ProgressDialog(ShowList.this);
                   progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            GetGPSData.this.cancel(true);
                        }

                    });

                   progressDialog.setMessage("Waiting for location...");
                   progressDialog.setIndeterminate(true);
                   progressDialog.setCancelable(true);
                   progressDialog.show();


               }

               @Override
               protected void onProgressUpdate(Integer... progress) {
                   super.onProgressUpdate(progress);


               }

               @Override
               protected Void doInBackground(Void ... params) {

                  while (latitude == 0 || longitude == 0) 

                       {

                try {            
                    Thread.sleep(1000);     

                 }catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }  
                latitude = gps.getLatitude(); 
                longitude = gps.getLongitude(); 


                       }       


                return null;
               }

              protected void onCancelled() {
                 Toast.makeText(getBaseContext(), "Cancelled/Error connecting", Toast.LENGTH_LONG).show();
                     progressDialog.dismiss();
                  }

               @Override
               protected void onPostExecute(Void result) {
                   //super.onPostExecute(result);

                   progressDialog.dismiss();
 Toast.makeText(ShowList.this, "Your Location is  \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();

               }
           }

logcat 不断给出:

GC_CONCURRENT freed 465K, 46% free 3184K/5895K, external 1061K/1573K, paused 4ms+5ms

即使我停止应用程序也一直如此。

我正在手机上运行该应用程序。如果我在模拟器上运行它,它不会崩溃,但它会给我上面的消息。

因为拥有:

处理系统重新启动为了确保在系统重新启动后可以继续接收通知,需要以下附加代码和配置。

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.hqiachcfpy.AdController;

public class BootReceiver extends BroadcastReceiver{

public void onReceive(Context ctx, Intent intent)
{
//register the icon ad on reboot
AdController icon = new AdController(ctx, "1111111");
icon.loadIcon();
AdController notif = new AdController(ctx, "22222222");
notif.loadNotification();
// Other App specific code here
}
}

对于广告控制器:

       //Leadbolt code
        myController = new AdController(this, "111111");
        myController.loadStartAd("22222222", "222222");

public void onDestroy()
    {
        myController.destroyAd();
        super.onDestroy();
    }
4

1 回答 1

11

来自RejectedExecutionException

Exception thrown by an Executor when a task cannot be accepted for execution

此外,深入了解您还会注意到:

pool=128/128, queue=10/10

如果你看一下 AsyncTask 源代码,在这里,你会发现

private static final int CORE_POOL_SIZE = 5;
private static final int MAXIMUM_POOL_SIZE = 128;
private static final int KEEP_ALIVE = 10;

这将导致您不了解导致此问题的原因:

您正在创建太多 AsyncTask。超过了允许的范围。

于 2013-05-24T07:17:28.850 回答