[英]Updating widget from configuration activity when home key is pressed
I am developing a widget and I am using the android:configure setting in the widget provider xml to setup the widget when first added on the home screen. 我正在开发一个窗口小部件,并且在窗口小部件提供程序xml中使用android:configure设置来首次将其添加到主屏幕时对其进行设置。 The problem is that this only works if the user taps the back key from the configuration activity.
问题是,这仅在用户从配置活动中点击返回键时有效。 If the user taps the HOME key, the widget is not added.
如果用户点击HOME键,则不会添加小部件。 Is there a way to add the widget on the home screen even of the user taps the Home key?
有没有办法即使用户点击Home键也可以在主屏幕上添加小部件?
Thanks 谢谢
I have found a workaround which seems to do the trick. 我发现一种解决方法似乎可以解决问题。 Here is what to do:
这是做什么的:
Instead of specifying the configuration activity in the widget provider xml, specify a different activity, for example StartActivity. 而不是在小部件提供程序xml中指定配置活动,而是指定其他活动,例如StartActivity。
In the constructor of the StartActivity do the following: 在StartActivity的构造函数中,执行以下操作:
In the onStop function of the configuration activity update the widget to reflect any changes that depend on any of the configuration settings. 在配置活动的onStop功能中,更新小部件以反映依赖于任何配置设置的任何更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.