2014-02-28 3 views
2

미러 API가 내 타임 라인에 삽입하는 카드가 있습니다.menuItems에 "OPEN_URI"메뉴 항목이 없습니다. 반환

카드에는 SCAN, REPLY, DELETE의 세 가지 옵션이 있습니다.

Expected-> 바코드 테스트 [SCAN은 REPLY, 삭제]
Received-> 바코드 테스트 [REPLY, 삭제]

답장 및 옵션은 메뉴 항목을 반환 삭제합니다. 내가 'OPEN_URI'를 'CUSTOM'으로 변경하면 돌아 오지만 내 android.scan을 엽니 다. (이것은 내 장치가 없습니다.)

나는 여기와 비슷한 단계를 밟았습니다. OPEN_URI 메뉴 항목은 페이로드에 대한 유효한 URI를 지정하는 것이 필요로하는 메뉴 아이템 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"} 
     ] 
    } 
) 

답변

3

를 만드는 방법에 대한 미러-API 문서. 우리를 위해

.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"} 
     ] 
    } ) 

또한 활동을 시작 OPEN_URI를 사용할 수 있습니다 웹 브라우저가 페이지를 엽니 전자, 이것은 단지 당신의 삽입이 그런 일을 보일 것이다 있도록 일반 데스크톱 웹 브라우저에 투입했던 것과 같이 표시됩니다 맞춤형 프로토콜을 사용하는 Android 앱에서

사용하려는 스캐너의 구현에 대해 잘 모릅니다. 그러나 여기에 자신의 GDK 앱용으로 연결하는 방법이 있습니다.

는이 같은 것을 추가하여 AndroidManifest.xml에서 사용자 지정 프로토콜을 지정해야합니다

<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> 

당신은 당신의 거울 API 타임 라인 항목에 해당 프로토콜이있는 URI를 지정해야합니다. 삽입 코드는 다음과 같이 보일 수 있습니다.

.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"} 
     ] 
    } 
) 
+0

안녕하세요, 제니 감사합니다. 문제는 여전히 지속됩니다. 'OPEN_URI'프로토콜이 클라이언트 또는 서버 측 유효성 검사를 수행합니까? 페이로드가 제대로 포맷되지 않았다고 생각합니다. 거울은 옵션을 던집니다. "payload": "SCAN : //com.google.zxing.client.android.SCAN", – stanzheng

+0

예, 맞춤 프로토콜 uri에 붙여 넣은 예제를 복사하고 서버 또는 유리가 요청을 구문 분석하여 미러 API를 복사합니다. 또는 장치가 이러한 작업을 수행합니까? 이 옵션을 건너 뜁니다. – stanzheng

+0

감사합니다. 난 내 애플 리케이션을 시작하는 프로토콜을 지정했다. "payload": "exampleprotocol". 클라이언트가 의도하지 않은 의도를 파싱했기 때문에 문제가 발생했습니다. – stanzheng