Sony SmartWatch - how to get host app package name

假装没事ソ 提交于 2019-12-23 03:16:43

问题


I would like to update the SmartWatch widget whenever the user changes the widget settings. I know it can be done by sending an WIDGET_IMAGE_UPDATE_INTEN intent, but it seems that I don't have the information of host app package name (i.e. com.sonyericsson.extras.smartwatch).

How can I get "host app package name"?

PS: Currently, I've hardwired the "com.sonyericsson.extras.smartwatch" name in my code.


回答1:


Every time your widget extension is receiving an intent from the host application, the package name of the host app is included as an extra in the intent.

String hostAppPackageName = intent.getStringExtra(Widget.Intents.EXTRA_AHA_PACKAGE_NAME);

You could store the package name for later use in your code. This is also how it is done in the utility classes of the SDK, i.e. it is stored as a global variable in the abstract class ExtensionService, which is used by all Sample extensions in the SDK.

Take a look at the SDK utility classes here



来源:https://stackoverflow.com/questions/10869538/sony-smartwatch-how-to-get-host-app-package-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!