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(); }