Android 打开系统最近任务及最近应用方法

Class serviceManagerClass;
                    try {
                        serviceManagerClass = Class.forName("android.os.ServiceManager");
                        Method getService = serviceManagerClass.getMethod("getService",
                                String.class);
                        IBinder retbinder = (IBinder) getService.invoke(
                                serviceManagerClass, "statusbar");
                        Class statusBarClass = Class.forName(retbinder
                                .getInterfaceDescriptor());
                        Object statusBarObject = statusBarClass.getClasses()[0].getMethod(
                                "asInterface", IBinder.class).invoke(null,
                                new Object[] { retbinder });
                        Method clearAll = statusBarClass.getMethod("toggleRecentApps");
                        clearAll.setAccessible(true);
                        clearAll.invoke(statusBarObject);
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
  

  

posted @ 2016-01-15 09:11  Coding-Null  阅读(2026)  评论(0编辑  收藏  举报