2013-08-19 32 views
0

我想顯示我的智能手錶上我現有的應用程序XYZ的輸出(位圖)。據我所知,控制API是要走的路,但索尼SDK和OpenSource項目(8Game和MusicPlayer)現有的例子並不清楚。我是否正確地假設,我需要將以下類集成到我現有的應用程序中?索尼SmartWatch控制擴展,從我的應用程序顯示一個視圖

  • MyControlWatch.java
  • MyExtensionReceiver.java
  • MyExtensionService.java
  • MyRegistrationInformation.java

些什麼,我需要,我如何得到的SmartWatch顯示我的位圖?我是否必須發送CONTROL_START_REQUEST_INTENT,如果是的話,我應該在哪裏做?我必須從給定的SampleControlExtension更改以獲得我的結果?

回答

1

是的,這些是你需要顯示控制擴展的類。您無需發送CONTROL_START_REQUEST_INTENT。這是隻有當你想從另一個擴展啓動你的控制擴展。

查看包含在SDK的/ samples目錄中的SampleControlSmartWatch.java類中的示例代碼。檢查一個示例的Animation()類構造函數。基本上你需要創建一個佈局,然後添加你的位圖,然後調用showBitmap()。

0

索尼應該創建迷你教程爲可用於這樣的事情u.u

/** * 這是如何更新整個佈局和一些 *觀點的例子。對於每個視圖,都使用一個包。該包必須具有佈局 *參考,即視圖ID和要使用的內容。此方法 *更新ImageView和TextView。 * * @see Control.Intents#EXTRA_DATA_XML_LAYOUT * @see Registration.LayoutSupport */

private void updateLayout() { 
    mCount = 0; 
    mIconImage = true; 

    String caption = mContext.getString(R.string.text_tap_to_update); 

    // Prepare a bundle to update the button text. 
    Bundle bundle1 = new Bundle(); 
    bundle1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.btn_update_this); 
    bundle1.putString(Control.Intents.EXTRA_TEXT, caption); 

    // Prepare a bundle to update the ImageView image. 
    Bundle bundle2 = new Bundle(); 
    bundle2.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.image); 
    bundle2.putString(Control.Intents.EXTRA_DATA_URI, 
      ExtensionUtils.getUriString(mContext, R.drawable.icon_extension48)); 

    Bundle[] bundleData = new Bundle[2]; 
    bundleData[0] = bundle1; 
    bundleData[1] = bundle2; 

    showLayout(R.layout.layout, bundleData); 
} 
相關問題