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 (Exception e) {
e.printStackTrace();
}
Android打开最近任务列表代码
·
45字
·
1分钟