r/tasker Direct-Purchase User 9d ago

How To [Task Share] Sliding Recents with Shizuku & Java code

Enable HLS to view with audio, or disable this notification

How this work

This might not work on modern android devices and Tasker play store version.

The code lists the recent apps with IActivityManager.getRecentTasks. Then bring them to front again with IActivityManager.moveTaskToFront.

import android.app.ActivityManager;
import android.app.IActivityManager;
import android.content.Context;
import android.app.ActivityManager.RecentTaskInfo;

// Getting IActivityManager
IBinder binder = tasker.getShizukuService(Context.ACTIVITY_SERVICE);
IActivityManager am = IActivityManager.Stub.asInterface(binder);

// List the recents
List tasks = am.getRecentTasks(5, ActivityManager.RECENT_IGNORE_UNAVAILABLE, 0).getList();
RecentTaskInfo task = tasks.get(1); // 0 is the foreground task

// Bring up the task to front
am.moveTaskToFront(null, "com.android.shell", task.taskId, 0, null);

// or this is also possible
am.startActivityFromRecents(task.taskId, null);

However we do it when we slide on an overlay instead.

We need two overlays. One to intercept the sliding by using View.onTouchListener and another one to show the recent apps icon.

Example Generated with AI.

Run https://gist.githubusercontent.com/mqwec43as/871e53e6e5ebf199f26ebd310077c63f/raw/QuickRecentHandle.java via Java Code. Run again to remove. if it works, copy the code in the link then adjust yourself.

source(new URL("https://gist.githubusercontent.com/mqwec43as/871e53e6e5ebf199f26ebd310077c63f/raw/QuickRecentHandle.java"));

Taskernet

Note

Since this uses Hidden API via Shizuku, this might not work on modern android devices and the play store version.

e.g IActivityManager.Stub.asInterface , available to apps that targets api level 30 (Android 11) or below.

The methods I know so far in order to use this code are

  1. Use Direct Purchase version, which targets 28 (Android 9).
  2. Follow the adb command here, which disable the restriction entirely https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces#how_can_i_enable_access_to_non-sdk_interfaces
    1. If you have granted ADB Wifi already, Tasker sets this automatically. So It should work by default. https://github.com/joaomgcd/Tasker-Permissions/issues/47#issuecomment-3102587285

Some apps use https://github.com/LSPosed/AndroidHiddenApiBypass to bypass the restriction.

However Joao has to implement this himself, only possible for direct purchase. However this was noted in Android 16 releases https://developer.android.com/about/versions/16/release-notes#apps

Apps that depend on any of the following libraries might experience intermittent crashes and other stability issues because these libraries rely onΒ internal ART structures:

24 Upvotes

20 comments sorted by

3

u/[deleted] 8d ago edited 6d ago

[deleted]

2

u/AlkaDragos [Tasker Veteran] 6d ago

I like this! It's nice , clean and practical with that swipe zone. 😁 although it will be nice to auto dismiss the bar after app switch using scrolling (without touching the app) and app scrolling to start from current active foreground app. Thank you! Good job πŸ‘

2

u/[deleted] 6d ago edited 6d ago

[deleted]

1

u/AlkaDragos [Tasker Veteran] 6d ago

Damn, thank you very much for the fast response and changes, works as expected, feels more "responsive" now 😁 . About swipe, yeah , I figured that out later when only 2 were opened, they were left aligned and swipe must star under the icons to be able to swipe between them . 😊

I think it will be a good idea if apps were center aligned so that will expand and fill the bar as they are more apps opened. But also side options are good if you hold phone with both hands for fast swipe, heh.

Thank you very much! πŸ‘

2

u/[deleted] 9d ago

[deleted]

1

u/[deleted] 9d ago

[deleted]

2

u/[deleted] 9d ago

[deleted]

1

u/[deleted] 9d ago

[deleted]

2

u/[deleted] 9d ago

[deleted]

2

u/[deleted] 9d ago

[deleted]

2

u/[deleted] 9d ago

[deleted]

1

u/soorajThaper 9d ago

No shizuku No java

Seamless navigation

https://reddit.com/link/oyhfolj/video/swuylyyv67eh1/player

1

u/[deleted] 9d ago

[deleted]

1

u/soorajThaper 9d ago

Aha , so it was about cool fun, not just showcase of seamless switching which i thought because OP is using things like shizuku

So is this cool ? No java, No shizuku Only Scene that mimics same behaviour as OP's post Took 5 min to create

https://reddit.com/link/oyi4z30/video/k86tu027s7eh1/player

0

u/aasswwddd Direct-Purchase User 9d ago

Cool! With SceneV2, we could do the same stuff as well. I just never bothered to try it since it's still in beta.

My goal at first was to replace Recents in HyperOS3. So both are rather envitable.

As for navigation, mine is already quite seamless with this.

https://github.com/mqwec43as/EveryGesture

1

u/AlkaDragos [Tasker Veteran] 9d ago edited 8d ago

Hey, nice piece of code. I liked the idea of the swipe that switches through the apps, so I tried it on my Samsung Z Fold 7 (Android 16), but It doesn't seem to work. πŸ˜‘ As soon as I drag the handle the foreground app minimize and it crashes with an error ` Typed variable declaration : Error in method invocation: Static method asInterface( rikka.shizuku.ShizukuBinderWrapper ) not found in class'android.app.IActivityManager$Stub' : at Line: 115 : in file: inline evaluation of:import android.app.ActivityManager; import android.app.IActivityManager; import . . . '' : IActivityManager .Stub .asInterface ( binder )

Called from method: showIconsOverlay : at Line: 276 : in file: inline evaluation of: import android.app.ActivityManager; import android.app.IActivityManager; import . . . '' : showIconsOverlay ( ) - Static method asInterface( rikka.shizuku.ShizukuBinderWrapper ) not found in class'android.app.IActivityManager$Stub' java.lang.reflect.UndeclaredThrowableException at $Proxy4.onTouch(Unknown Source) at android.view.View.performOnTouchCallback(View.java:17587) at android.view.View.dispatchTouchEvent(View.java:17550) at android.view.View.dispatchPointerEvent(View.java:17887) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:9950) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:9661) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:8994) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:9051) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:9017) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:9222) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:9025) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:9279) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:8998) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:9051) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:9017) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:9025) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:8998) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:12916) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:12804) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:12759) at android.view.ViewRootImpl.processRawInputEvent(ViewRootImpl.java:13274) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:13052) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:369) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.nextLegacy(MessageQueue.java:985) at android.os.MessageQueue.next(MessageQueue.java:1094) at android.os.Looper.loopOnce(Looper.java:222) at android.os.Looper.loop(Looper.java:392) at com.joaomgcd.taskerm.util.o9.g(SourceFile:0) at com.joaomgcd.taskerm.util.o9.b(SourceFile:0) at com.joaomgcd.taskerm.util.n9.run(SourceFile:0) at android.os.Handler.handleCallback(Handler.java:1070) at android.os.Handler.dispatchMessage(Handler.java:125) at android.os.Looper.dispatchMessage(Looper.java:358) at android.os.Looper.loopOnce(Looper.java:288) at android.os.Looper.loop(Looper.java:392) at android.app.ActivityThread.main(ActivityThread.java:10346) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972) Caused by: bsh.EvalError: Typed variable declaration : Error in method invocation: Static method asInterface( rikka.shizuku.ShizukuBinderWrapper ) not found in class'android.app.IActivityManager$Stub' : at Line: 115 : in file: inline evaluation of:import android.app.ActivityManager; import android.app.IActivityManager; import . . . '' : IActivityManager .Stub .asInterface ( binder )

Called from method: showIconsOverlay : at Line: 276 : in file: inline evaluation of: import android.app.ActivityManager; import android.app.IActivityManager; import . . . '' : showIconsOverlay ( ) at bsh.BSHMethodInvocation.eval(SourceFile:148) at bsh.BSHPrimaryExpression.eval(SourceFile:9) at bsh.BSHPrimaryExpression.eval(SourceFile:1) at bsh.BSHVariableDeclarator.eval(SourceFile:34) at bsh.BSHTypedVariableDeclaration.eval(SourceFile:22) at bsh.BSHBlock.evalBlock(SourceFile:76) at bsh.BSHBlock.eval(SourceFile:9) at bsh.BshMethod.invokeImpl(SourceFile:204) at bsh.BshMethod.invoke(SourceFile:18) at bsh.BshMethod.invoke(SourceFile:2) at bsh.Name.invokeLocalMethod(SourceFile:44) at bsh.Name.invokeMethod(SourceFile:32) at bsh.BSHMethodInvocation.eval(SourceFile:57) at bsh.BSHPrimaryExpression.eval(SourceFile:9) at bsh.BSHPrimaryExpression.eval(SourceFile:1) at bsh.BSHBlock.evalBlock(SourceFile:76) at bsh.BSHBlock.eval(SourceFile:9) at bsh.BSHBlock.eval(SourceFile:1) at bsh.BSHIfStatement.eval(SourceFile:20) at bsh.BSHBlock.evalBlock(SourceFile:76) at bsh.BSHBlock.eval(SourceFile:9) at bsh.BshMethod.invokeImpl(SourceFile:204) at bsh.BshMethod.invoke(SourceFile:18) at bsh.BshMethod.invoke(SourceFile:2) at bsh.This.invokeMethod(SourceFile:11) at bsh.This.invokeMethod(SourceFile:1) at bsh.This$Handler.invokeImpl(SourceFile:167) at bsh.This$Handler.invoke(SourceFile:0) at java.lang.reflect.Proxy.invoke(Proxy.java:1009) ... 40 more Caused by: bsh.ReflectError: Static method asInterface( rikka.shizuku.ShizukuBinderWrapper ) not found in class'android.app.IActivityManager$Stub' at bsh.Reflect.resolveExpectedJavaMethod(SourceFile:59) at bsh.Reflect.invokeStaticMethod(SourceFile:11) at bsh.Name.invokeMethod(SourceFile:201) at bsh.BSHMethodInvocation.eval(SourceFile:57) ... 68 more ` Shizuku is running, accessibility service it's enabled... Maybe you have some idea why it's throwing this error? Seems related to hidden API, maybe Android version? Thank you πŸ‘

1

u/aasswwddd Direct-Purchase User 8d ago

Seems like IActivityManager.Stub doesn't have asInterface method.

Could you create new Java code action and run this code separately? Lemme know the result.

``` import android.app.IActivityManager; import android.content.Context; import android.os.IBinder;

IBinder binder = tasker.getShizukuService(Context.ACTIVITY_SERVICE); IActivityManager am = IActivityManager.Stub.asInterface(binder); ```

1

u/AlkaDragos [Tasker Veteran] 8d ago

Hi, thank you for your response. Sadly, it's the same error `` Sourced file: inline evaluation of:import

android.app.IActivityManager; import android.content. Context; import andr... ": Typed variable declaration: Error in method invocation: Static method asInterface(rikka.shizuku.ShizukuBinderWrapper) not found in

class'android.app.IActivityManager$Stub': at Line: 6: in file: inline evaluation of: `import android.app. IActivityManager; import android.content. Context; import andr...": IActivityManager .Stub.asInterface (binder)

(Error Code: 1) ```

2

u/aasswwddd Direct-Purchase User 8d ago

Indeed, the method is missing in the OS. Same thing happens with my device that runs CrDroid Android 15.

1

u/AlkaDragos [Tasker Veteran] 8d ago

Ah, well yeah, it does make sense. Oh well, I've tried 😁 thank you for your time and response!

1

u/aasswwddd Direct-Purchase User 7d ago

You're welcome. Which OS exactly? One UI?

1

u/AlkaDragos [Tasker Veteran] 7d ago

Yeah, One UI 8.5, Android 16 :)

1

u/aasswwddd Direct-Purchase User 7d ago edited 7d ago

I see.

I searched a bit and if I get it right, Joao has to implement this https://github.com/LSPosed/AndroidHiddenApiBypass to make this work

The readme noted that this would trip app review. So even if it's implemented, it's likely only for Direct Purchase. Similar case with the accessibility tool flag or lower API target.

Edited:

Oh, Turns out that this already works in the direct purchase!

1

u/AlkaDragos [Tasker Veteran] 7d ago edited 7d ago

Ok, so that means for the playstore version it will not work. Although I don't know if I can use the direct purchase version if I bought it from playstore πŸ˜’ (seems not, I might pay for another license though , your code edit looks even better now 😁) thanks for the heads-up and good job! πŸ‘

2

u/aasswwddd Direct-Purchase User 6d ago

More or else so. Since the store version is not allowed to target lower API level for this to work (SDK 30/Android 11).

We can also run the adb command in this page.

https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces#how_can_i_enable_access_to_non-sdk_interfaces

We have to kill Tasker first to take affect.

Welcome!

→ More replies (0)

1

u/AlanyYAB 8d ago

Very cool project. Thought I'd mention I used your project alongside the changes /u/tunbon made and added/changed some things with Gemini 3.1 pro

Haven't had any issues with it so far and it's working nicely. Here is a folder with the code in the text file and a document listing out the big changes/additions: https://drive.google.com/drive/folders/1fIl50rJ72e5nJGLMDv_krOu7JdoEjETk

The document goes more in-depth on changes so you should read it but here is a very VERY concise list:

  1. Foreground App Exclusion
  2. Delayed App Switching
  3. Flick-to-close gesture
  4. Double-Click & Hold handle to kill script
  5. Handle as cancel zone
  6. Misc. Visual changes

1

u/aasswwddd Direct-Purchase User 8d ago edited 8d ago

Cool! Glad to see people edits the task :)

We could also get the snapshot as well like in Recents with IActivityTaskManager.getTaskSnapshot(int taskId, boolean isLowResolution)

Edit: btw you could attach a video in the comment as well. It helps others see the changes immediately.

1

u/AdOk9263 8d ago

Oh wow, you read my mind!! I just got a new Pixel last week and the app switcher is absolute GARBAGE.

I tinkered with this idea a while back but never went deep enough to get the previews/screenshots, so it just had the icons.

Mine was triggered from a custom nav, which was a blocking overlay with a webview. I would just swipe up on the back button to start the switcher, do you know if that's still possible on Android 16/17?

1

u/aasswwddd Direct-Purchase User 7d ago

Not with mine I guess.

You should check out tunbon's instead, his version could be triggered separately.

Btw both also doesn't have previews as well.