Manually exit a widget (or simulate a keyevent)?

I made a widget showing a list of stats, because for new watches the list can be long it can be spread over 2 pages (and pressing/swiping up and down switches between the two by simply different drawing in onUpdate)

But one issue was that up/down buttons only work in glance enabled widgets (otherwise it will toggle between widgets) whcih I worked around by pushing a dummy view and immediately pushing the main view.

However, now when pressing back from the main view I get back in the dummy view and you have to press back once more to actually get out of the widget. Is there a way to do this automatically?

System.exit() and popView don't work... the first doesn't do anything it seems and the second isn't allowed.

Is there a way to emulate the back button press or a key event programmatically perhaps?

Top Replies

All Replies

  • With the dummy it was:

    * Non-glance: Dummy --immediately push/back--> Main View 1 <--up/down--> Main View 2  (From any main view <--select/back--> History Views (up/down)

    Sorry if I'm being dumb here, but are you saying that when the user scrolls to your non-glance widget, the top-level view is the Dummy view which automatically pushes Main View 1? If that's the case, that doesn't seem very user-friendly, as it breaks the flow of scrolling through all widgets. (i.e. i.e. if your widget manages to load while I'm trying to scroll past it, then all of a sudden I'm in your widget's set of screens)

    I wouldn't even think it's possible, although it is possible for a glance widget (where the top-level view of the full widget immediately pushes another view).

    If you meant that the Dummy view comes after a top-level view that you didn't mention, then couldn't you have this:

    Non-glance: Top-level -<--select/back--> Main View 1 <--up/down--> Main View 2  (From any main view <--select/back--> History Views (up/down)