2013年12月15日日曜日

java.lang.IllegalStateException: State CREATED expected, currently in PUBLISHED

12-15 13:42:36.562: E/AndroidRuntime(1905): FATAL EXCEPTION: main
12-15 13:42:36.562: E/AndroidRuntime(1905): java.lang.IllegalStateException: State CREATED expected, currently in PUBLISHED
12-15 13:42:36.562: E/AndroidRuntime(1905):     at com.google.android.glass.timeline.LiveCard.applyStateTransition(LiveCard.java:334)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at com.google.android.glass.timeline.LiveCard.publish(LiveCard.java:193)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at jp.nextsphere.positivesuppli.OrientationManager$1.onSensorChanged(OrientationManager.java:161)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at android.hardware.SensorManager$ListenerDelegate$1.handleMessage(SensorManager.java:580)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at android.os.Looper.loop(Looper.java:137)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at java.lang.reflect.Method.invokeNative(Native Method)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at java.lang.reflect.Method.invoke(Method.java:511)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-15 13:42:36.562: E/AndroidRuntime(1905):     at dalvik.system.NativeStart.main(Native Method)

いちど LiveCard#publish() をコールした LiveCard インスタンスに対し、もう一度 publish() をコールしてはいけない模様。

リファレンスには確かに
Note that once a card using RemoteViews is published, changes made to the views by calling set* methods will not be visible in the timeline unless you explicitly call setViews on the live card again to force an update. 
と書いてある。
 LiveCard を更新する場合は、LiveCard にセットした RemoteViews の set系のメソッドを使えと。

流れとしては、
                    RemoteViews rv = new RemoteViews(packageName,
                            R.layout.testlayout);
                    rv.setTextViewText(R.id.textViewResultCombo, "p= " + mPitch);
                    mLiveCard.setViews(rv);
という感じに、
RemoteViews を new して
 ↓
RemoteViews#set* でビューを更新して
 ↓
LiveCard#setViews() で RemoteViews をセット
という感じみたい。


0 件のコメント:

コメントを投稿