Android Studio中的ExecutionException被拒绝



我的应用程序(使用HERE Android SDK)在进行模拟逐轮导航时崩溃,异常日志如下,请告诉如何解决。

设备型号:SM-G9008V
SDK:5.0----------java.util.courrent.RejectedExecutionException:任务android.os.AsyncTask$3@36d584c9被拒绝java.util.concurrent.ThreadPoolExecutor@23d4f7ce[跑步,游泳池大小=9,活动线程=9,排队任务=128,已完成任务=828]java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)android.os.AsyncTask.executeOnExecutor(AsyncTask.java:590)com.nokia.maps.bf.c(LocationRestHandler.java:207)com.nokia.maps.bf.b(LocationRestHandler.java:198)com.nokia.maps.dn.b(PlacesVerseGeocodeRequest.java:256)com.nokia.maps.dn.a(PlacesVerseGeocodeRequest.java:28)com.nokia.maps.dn$1.run(PlacesVerseGeocodeRequest.java:104)android.os.Handler.handleCallback(Handler.java:739)android.os.Handler.dispatchMessage(Handler.java:95)android.os.Looper.loop(Looper.java:145)android.app.ActivityThread.main(ActivityThread.java:5835)java.lang.reflect.Method.ioke(本机方法)java.lang.reflect.Method.ioke(Method.java:372)com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)com.android.internal.os.ZygoteInit.main(ZygoteNit.java:1194)

您是否同时发出多个请求?您似乎发出了太多请求,并且超过了未处理的最大数量:

java.util.concurrent.ThreadPoolExecutor@23d4f7ce[正在运行,池大小=9,活动线程=9,排队任务=128,已完成任务=828]

你在导航代码中做什么?你能发布一个片段吗?

为什么我会收到这个错误消息?

如果超过了ThreadPoolExecutor可以排队的任务数,则会收到此错误消息。唯一一次抛出RejectedExecutionException是由默认RejectedExecutionHandlerThreadPoolExecutor.AbortPolicy引发的。

引用javadocs:

如果请求无法排队,则会创建一个新线程,除非将超过最大PoolSize,在这种情况下,任务将被拒绝。

有最大数量的任务。请参阅此处的问题/答案:同时执行的AsyncTasks有限制吗?

@David,下面是代码片段:

if(navigationManager == null) {
            navigationManager = NavigationManager.getInstance();
            navigationManager.setMap(map);
        }
        // start listening to navigation events
        instructListener = new InstructListener();
        navigationManager.addNewInstructionEventListener(
                new WeakReference<NavigationManager.NewInstructionEventListener>(instructListener));
        // start listening to position events
        if (naviPositionListener == null) {
            naviPositionListener = new NaviPositionListener();
        }
        navigationManager.addPositionListener(
                new WeakReference<NavigationManager.PositionListener>(naviPositionListener));
        if (maneuverEventListener == null) {
            maneuverEventListener = new ManeuverEventListener();
        }
        navigationManager.addManeuverEventListener(
                new WeakReference<NavigationManager.ManeuverEventListener>(maneuverEventListener));

        if (myNavigationManagerEventListener == null) {
            myNavigationManagerEventListener = new MyNavigationManagerEventListener();
        }
        navigationManager.addNavigationManagerEventListener(new WeakReference<NavigationManager.NavigationManagerEventListener>(myNavigationManagerEventListener));
        if (rerouteListener == null) {
            rerouteListener = new MyRerouteListener();
        }
        navigationManager.addRerouteListener(new WeakReference<RerouteListener>(rerouteListener));
        if (safetySpotListener == null) {
            safetySpotListener = new MySafetySpotListener();
        }
        navigationManager.addSafetySpotListener(new WeakReference<NavigationManager.SafetySpotListener>(safetySpotListener));
        //add realistic view listener
        navigationManager.setRealisticViewMode(NavigationManager.RealisticViewMode.DAY);
        navigationManager.addRealisticViewAspectRatio(NavigationManager.AspectRatio.AR_4x3);
        if (realisticViewListener == null) {
            realisticViewListener = new MyRealisticViewListener();
        }
        navigationManager.addRealisticViewListener(
                new WeakReference<NavigationManager.RealisticViewListener>(realisticViewListener));

        //set map udpate mode
        navigationManager.setMapUpdateMode(NavigationManager.MapUpdateMode.ROADVIEW);
        navigationManager.setTrafficAvoidanceMode(NavigationManager.TrafficAvoidanceMode.DISABLE);
        //set natural guidance mode
        EnumSet<NavigationManager.NaturalGuidanceMode> modeset = navigationManager.getNaturalGuidanceMode();
        modeset.add(NavigationManager.NaturalGuidanceMode.TRAFFIC_LIGHT);
        modeset.add(NavigationManager.NaturalGuidanceMode.STOP_SIGN);
        modeset.add(NavigationManager.NaturalGuidanceMode.JUNCTION);
        navigationManager.setNaturalGuidanceMode(modeset);
        // add gps signal listener
        if (gpsSignalListener == null) {
            gpsSignalListener = new MyGpsSignalListener();
        }
        navigationManager.addGpsSignalListener(new WeakReference<NavigationManager.GpsSignalListener>(gpsSignalListener));

        if (speedWarningListener == null) {
            speedWarningListener = new MySpeedWarningListener();
        }
        navigationManager.addSpeedWarningListener(new WeakReference<NavigationManager.SpeedWarningListener>(speedWarningListener));
        //add lane info listener
        if (laneInfoListener == null) {
            laneInfoListener = new MyLaneInfoListener();
        }
        navigationManager.addLaneInfoListener(new WeakReference<NavigationManager.LaneInfoListener>(laneInfoListener));

        navigationManager.getRoadView().setOrientation(NavigationManager.RoadView.Orientation.DYNAMIC);
        navigationManager.getRoadView().addListener(new WeakReference<NavigationManager.RoadView.Listener>(roadViewListener));

        //start navigation
        long speed = 60; // meter per second
    navigationManager.simulate(mapRoute.getRoute(), speed);

相关内容

  • 没有找到相关文章

最新更新