5

I'd like to make use of an Android tablet to write on OneNote pages that I'm actively viewing in a Windows computer. From the Windows computer, I get two links when I right click on a page and select "Copy link to page". These links look like the following:

https://onedrive.live.com/view.aspx?resid=...
onenote:https://d.docs.live.net/...

The second link that starts with onenote:https://d... is useful when I want to jump to the page on another Windows computer - I can feed it to the Run window, and the OneNote app will display the page I need it to go to.


Question: with adb, can I achieve a similar operation by feeding the second link to the Android tablet, through some "intent"? I know very little about Java and have no idea how to make use of these related posts. Mainly, I'm looking for a long adb command with appropriate flags that may take, likely, the second link as input and have the Android tablet open the page by responding to some intent.

Eventually, with the long adb command, I see myself wrapping it in a bash function, and calling it by feeding in the full link that starts with onenote:https://d....


Update1: thanks to user M. A.'s answer, I can send the onenote:https://d.docs.live.net/... link to the Android tablet - However, OneNote APK seems to only comprehend up to the section name in the onenote:... link despite the whole thing consists of page-specific pointers.

Here is a demo where I fed in a full link pointing to a page, which was sent as an intent to only go to the relevant section. enter image description here

PS: in OneNote, things are organized as Notebook/Section/Page/Subpage. In the screenshot above, the Notebook is "Paperless", and I have masked out the name for the section and page.


Update2: for the full page-specific URL to work, we actually need to escape the & signs in &section-id, &page-id and &end.

1

2 Answers 2

7

When you have OneNote APK installed on your mobile phone, try this:

adb shell am start -a "android.intent.action.VIEW" -d " \"onenote:https://d.docs.live.net/....\" "

Note, the &section-id, &page-id and &end bits in the onenote:https://... URL will draw special attention from the interpreter (see Update 1 in the original question).

Spikatrix offered a simpler solution in the comment below: to wrap the whole OneNote link first as a string with quotation marks escaped, and then add another pair of quotes to pass the string to the shell.

5
  • Thanks for your help. Is there a special trick to wrap the URL fed through the -d flag? Per my updated screenshots, it seems like either the adb or the "shell on the Android tablet(?)" was trying to make more sense out of &section-id, &page-id and &end.
    – llinfeng
    Jun 30 at 11:26
  • I tried to escape & as \& in the URL, and it worked!
    – llinfeng
    Jun 30 at 11:27
  • Oh, I should have asked this before updating your reply - is there an out-of-the-box way to escape those & signs in the URL?
    – llinfeng
    Jun 30 at 11:30
  • 2
    @llinfeng Try wrapping the entire string in quotes like so: "one & two" would be "\"one & two\""
    – Spikatrix
    Jul 1 at 5:18
  • @Spikatrix Perfect! This worked better than escaping & signs! I ended up passing the OneNote link as " \"onenote:https://...&section-id={xxx}...&end\" ". (I added two spaces to make the inner string stand out.)
    – llinfeng
    Jul 1 at 14:59
1

I ended up using the method documented in this gist: https://gist.github.com/llinfeng/affd7911645d7e8502b20d6f0a612842. In general, I find it helpful that Github "gists" should have better version control, and decide to leave all the code component there in a public gist.

The method described in the gist works in three steps:

  1. Create a parser script that deal with the bits that contain &, namely, these three: &section-id, &page-id and &end
  2. Create a wrapper function in Zsh that will pass the long OneNote string into the parser script, and
  3. Create an alias in Zsh that can activate the wrapper function in step 2 with one as a shorthand.

With the alias defined there, issuing one "LongLink2Page" in Zsh will get the page loaded on the Android tablet. Future improvement would be to update the parser script to read directly from the clipboard.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .