You are browsing as a guest. Sign up (or log in) to start making projects!

1h 49m 44s logged

android-desktop is live!

Just published my second npm package, this time for working with app windows on android’s desktop mode for external displays.

Now that this is polished I’ll officially be moving on to the hardware stage, I’ll just need to get funding for a monitor, stereo amplifier, 12V to 20V booster, and I should be good to start building.

Usage

parseDisplayInfo(data)

Parses a DisplayInfo object to JSON. This is mainly intended to be used internally by getDisplays().

  • data: A string containing DisplayInfo data. See the DisplayInfo source (especially the toString() function) for more info.

getDisplays()

Returns an array of DisplayInfo objects. See https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/DisplayInfo.java for more info on what’s included. To avoid issues when translationg to a JSON structure, any entries that were singular values rather than key/value pairs are put inside a _flags array, since most are intended to be flags. However, as you can see in the toString() function of the DisplayInfo source linked above, the first value entered is always the name of the device, so this will always be the first item in _flags.

getDensity(displayId)

Returns the dpi of a given display.

  • displayId: The id of the display

setDensity(displayId)

Sets the dpi of a given display. This can be useful for scaling app content.

  • displayId: The id of the display

startActivity(displayId, pkg, forceStart)

Starts an activity on a given display. If forceStart is set to true

  • displayId: The id of the display
  • pkg: The package name of the app to start. Some apps may require you to include an intent as well.
  • forceStart: If true, the app is closed and reopened, which can help with stability. Set to true by default.

getTaskId(displayId, pkg)

Returns the task id of an app on a given display. Returns null if it couldn’t be found.

  • displayId: The id of the display.
  • pkg: The package name of the app.

resizeTask(taskId, x1, y1, x2, y2)

Sets the position and size of an app window on external displays in desktop mode.

  • taskId: The task id of the app.
  • x1: The x coordinate to move the top left corner to.
  • y1: The y coordinate to move the top left corner to.
  • x2: The x coordinate to move the bottom right corner to.
  • y2: The y coordinate to move the bottom right corner to.
0
4

Comments 0

No comments yet. Be the first!