Connect IQ > プログラムの基本(App.mc)

概要

プログラム本体?とViewから構成される。
  • 本体はAppBaseを継承
    • ここからViewを呼び出す(登録する?)
  • ViewはViewを継承

全てのアプリケーションは Applicationオブジェクトを含み、エントリポイントとなる。
Eclipseプラグインは、これを自動的に生成する。

Application オブジェクトは getInitialView() をオーバーライドする必要があり、ヴューを最初にプッシュする。そして、 view と delegate を持つ配列、もしくは view 一要素のみを持つ配列を返す必要がある。

return [ new MyView(), new MyDelegate() ];

AppBase

基本のクラスとなる。
  • 全てアプリははこのクラスを継承する
  • widgets,watch-appsでは、次の順序で呼ばれる
    1. onStart()
      • ここでアプリケーションレベルの初期化が行わる
      • ビューが作られる前に実施される
    2. getInitialView()
      • アプリケーションのWatchUi.Viewを戻り値に設定(必須)。いわゆる見た目。
      • widget,watchi-appsではアプリケーションのWatchUi.InputDelegateを戻り値に設定できる(入力を扱いたければ。)
        • Widget, Data Fieldsでは設定できない。(入力を受け取れない。)
      • WatchUi.View(とWatchUi.InputDelegateの)配列を戻り値にする。
    3. onStop()
      • アプリケーションが終わろうとするときに呼ばれる。
      • 終了前にデータや状態を格納しておく必要がある場合は、ここに記述する


  • Every AppBase object has access to an objectstore to persist data.
  • getProperty(key), setProperty(key,object)
    • getPropertyは、object storeから与えられたkeyのデータを得る関数
    • keyはシンボルはダメ
    • 戻り値はオブジェクト(なければnull)

using Toybox.Application as App;

class GarminTestApp extends App.AppBase {

    function initialize() {
        AppBase.initialize();
    }

    //! onStart() is called on application start up
    function onStart() {
    }

    //! onStop() is called when your application is exiting
    function onStop() {
    }

    //! Return the initial view of your application here
    function getInitialView() {
        return [ new GarminTestView() ];
    }

}

Products


Garmin makes a wide variety of products for many use cases, and Monkey C makes it easy to write for all our Connect IQ compatible devices. Monkey C asks the developer which Connect IQ devices they choose to support because it is impossible to know whether a future product may be incompatible with your app. As new Connect IQ compatible products appear on the market, the simulator will be updated to support them so developers can decide whether to support them.

The SDK currently supports two imaginary products designed for general prototyping—a round-watch and a square-watch—along with all currently supported production devices (e.g. Forerunner 920XT, fēnix 3, etc.). The round watch is button only, and the square watch is a touch screen product with fewer buttons.

Products supported by an app are listed in the products block of the manifest file:

<iq:products>
   <iq:product id="round-watch"/>
</iq:products>

Permissions

Certain modules expose personal information about the user or expose communication to the internet. To use these modules, permission must be requested from the user at installation time. To request permission, the module name must be added to the permissions list of the manifest file. The following modules require permission:

   ActivityRecording
   Communications
   Positioning
   Sensor
   UserProfile

More modules may be added to this list as modules are added to the API. To request permission, use the following syntax in the manifest file:

<iq:permissions>
   <iq:uses-permission id="Sensor"/>
</iq:permissions>
最終更新:2018年04月08日 21:00