Sony Smartwatch - update text in multiple TextView

2019-08-18 03:03发布

I would like to update the text in the two TextViews on the Watch simultaneously.

main_layout.xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <TextView
        android:id="@+id/text1"
        android:layout_width="220px"
        android:layout_height="50px"
        />
    <TextView
        android:id="@+id/text2"
        android:layout_width="220px"
        android:layout_height="50px"
        />
</LinearLayout>

Now I'm doing it this way:

sendText(R.id.text1, "Hello world 1");
sendText(R.id.text2, "Hello world 2");

The problem is, that I can see on the Watch, that the first text is set earlier, then the second one. And I would like to avoid that.

Generally, Sony-SDK supports the data-updates in bundles, for example when showing a layout:

Bundle b1 = new Bundle();
b1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text1);
b1.putString(Control.Intents.EXTRA_TEXT, "Hello world 1");

Bundle b2 = new Bundle();
b2.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text2);
b2.putString(Control.Intents.EXTRA_DATA_URI, "Hello world 2");

Bundle[] layoutData = new Bundle[] { b1, b2 };

showLayout(R.layout.main_layout, layoutData);

but in this case the layout is re-set, which is not so good in my case, because some other views on the screen may already have been changed.

I hoped, it could be possible to achieve this through something like:

Bundle bundle = new Bundle();
bundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text2);
bundle.putString(Control.Intents.EXTRA_TEXT, "Hello world 2");

Intent intent = new Intent(Control.Intents.CONTROL_SEND_TEXT_INTENT);

intent.putExtra(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text1);
intent.putExtra(Control.Intents.EXTRA_TEXT, "Hello world 1");

intent.putExtra(Control.Intents.EXTRA_LAYOUT_DATA, new Bundle[] { bundle });

sendToHostApp(intent);

but unfortunately the Watch seems to ignore the EXTRA_LAYOUT_DATA for the CONTROL_SEND_TEXT_INTENT intent.

So my question is: is there any possibility to send text updates as a bundle without re-setting the layout?

1条回答
放荡不羁爱自由
2楼-- · 2019-08-18 03:21

You're doing it right. Updating the whole screen would be the best way, just update all other fields that might have changed in meantime also.

查看更多
登录 后发表回答