Show recent apps programmatically on android oreo -


i want somehow immitate recent apps hard button click opens native android recent apps screen.

i following currently:

boolean success = showrecents1(c); if (!success) {     showrecents2(c); } 

this works on lot of devices, on android oreo emulator not work. know solution works on android oreo well?

private boolean showrecents1(context c) {     try {         intent intent = new intent("com.android.systemui.recent.action.toggle_recents");         intent.setcomponent(new componentname("com.android.systemui", "com.android.systemui.recent.recentsactivity"));         c.startactivity(intent);         return true;     } catch (exception e) {         l.e(e);     }     return false; }  private boolean showrecents2(context c) {     try {         class 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);         return true;     } catch (exception e) {         l.e(e);     }     return false; } 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -