退出近期运行的所有APP应用方法:
public void exitAllApp() throws RemoteException, UiObjectNotFoundException, InterruptedException{
UiDevice.getInstance().pressRecentApps();
UiObject recentapp = new UiObject(new UiSelector().resourceId("com.android.systemui:id/dismiss_task"));
do{
recentapp.waitForExists(2000);
if(recentapp.exists()){
recentapp.swipeLeft(5);
}
}while(recentapp.exists());
}