Question

I have a card that is being inserted in my timeline by the mirror api.

The card has 3 options: SCAN, REPLY, DELETE.

Expected-> Barcode Test[SCAN, REPLY, DELETE]
Received-> Barcode Test[REPLY, DELETE]

The Reply and Delete options only return on menu item. If i change 'OPEN_URI' to 'CUSTOM" it returns but does not do what I hope to do, which is open my android.scan.(this is present no my device)

I followed similar steps to here and on the Mirror-API docs about creating the menuItems https://developers.google.com/glass/v1/reference/timeline#menuItems

Opening GDK Glassware through Mirror API Glassware MenuItem

 .mirror.timeline.insert(
    {
        "text": "Barcode Test",
        "callbackUrl": "https://mirrornotifications.appspot.com/forward?url=http://localhost:8081/reply",
        "menuItems": [
            {
              "action": "OPEN_URI",
              "id": "complete",
              "payload": "com.google.zxing.client.android.SCAN",
              "values": [{
                "displayName": "Scan",
                "iconUrl":"com.google.zxing.client.android.SCAN"
              }]
            },
            {"action": "REPLY"},
            {"action": "DELETE"}
        ]
    }
  )
Was it helpful?

Solution

The OPEN_URI menu item requires that you specify a valid URI for the payload.

To use the web browser to open a page, this will look just like what you'd put into a normal desktop web browser so your insertion would look something like that:

 .mirror.timeline.insert(
    {
        "text": "Barcode Test",
        "callbackUrl": "https://mirrornotifications.appspot.com/forward?url=http://localhost:8081/reply",
        "menuItems": [
            {
              "action": "OPEN_URI",
              "id": "complete",
              "payload": "http://example.com",
              "values": [{
                "displayName": "Scan",
                "iconUrl":"http://example.com/icon.png"
              }]
            },
            {"action": "REPLY"},
            {"action": "DELETE"}
        ]
    }   )

You can also use OPEN_URI to initiate an activity on an android app using a custom protocol.

I don't know much about the implementation of the scanner you are trying to use, but here's how you'd wire it up for your own GDK app.

You need to specify the custom protocol in your AndroidManifest.xml by adding something like this:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.BROWSABLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="exampleprotocol" />
</intent-filter>

You must specify a URI with that protocol in your Mirror API timeline item. Your insert code might look something like this:

 .mirror.timeline.insert(
    {
        "text": "Barcode Test",
        "callbackUrl": "https://mirrornotifications.appspot.com/forward?url=http://localhost:8081/reply",
        "menuItems": [
            {
              "action": "OPEN_URI",
              "id": "complete",
              "payload": "exampleprotocol://scan",
              "values": [{
                "displayName": "Scan",
                "iconUrl":"http://example.com/scan.png"
              }]
            },
            {"action": "REPLY"},
            {"action": "DELETE"}
        ]
    }
  )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top