Skip to content

Overlay doesn't work without specifying tid #4

@cheadrian

Description

@cheadrian

When creating an overlay activity without specifying TID, there's an error about unpack.
Python 3.11.6, termuxgui 0.1.6 running on Android 12, MIUI 14.

The code that is not working as expected:

import termuxgui as tg
import time

def main():
    with tg.Connection() as connection:
        activity = tg.Activity(connection, overlay=True)
        tv = tg.TextView(activity, "Hello world!")
        time.sleep(10)

if __name__ == "__main__":
    main()

Error:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/mergebot/bot_gui_overlay.py", line 11, in <module>
    main()
  File "/data/data/com.termux/files/home/mergebot/bot_gui_overlay.py", line 6, in main
    activity = tg.Activity(connection, overlay=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/termuxgui/activity.py", line 29, in __init__
    self.aid, tid = self.c.send_read_msg({"method": "newActivity", "params": params})
    ^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable int object

Adding a random tid to the tg.Activity makes the overlay to appear and fix the problem

activity = tg.Activity(connection, tid=123, overlay=True)

The overlay activity isn't documented in the TUTORIAL.md and would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions