自动屏幕旋转禁用窗口小部件远程视窗onClick事件 [英] Auto Screen Rotation Disabling Widget RemoteView onClick event

查看:140
本文介绍了自动屏幕旋转禁用窗口小部件远程视窗onClick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一点奇怪的bug与小窗口我有codeD-屏幕旋转部件停止响应的onClick事件之后。在code是完全一样,这里 Android的开发者文档>。我注意到其他部件从市场上没有这个problem-有没有已知的解决方法吧?我试着窃听所有的地方旋转后,所以我不认为它的​​onClickPendingIntent不是一个旋转之后被调整;它似乎并不为present的。

我找不到onRotation()种触发的AppWidgetProvider重做听音code在旋转,所以我相当不确定如何进行事件......

谢谢!

解决方案

我收到后我做了对谷歌论坛它解决了我的问题如下回应。我不能说是否会解决楼主的问题,但是我虽然我将它张贴,万一别人过这个问题上运行。链接到我的谷歌论坛帖子是:

http://groups.google.com/group/android-developers/browse_thread/thread/ca8c2958b6dc086c#


  
    

上有配置更改没有的onupdate。主屏幕再现     你的部件,然后把最新的RemoteViews,并将其应用到     窗口小部件。

  
     

我想,这是重新创建了Widget上旋转。问题   是,我似乎并没有得到任何消息的作用,并有   重新建立连接没有办法(我可以看到)。我怎么能够   确定一个旋转已经发生,并成立了新的onClick   连接?

就像我说的,你不(或确定一个方向变化做出反应)。

你做了什么,是确保您的每一次code推送RemoteViews 对象到您的插件的家庭应用,它是完全在所有 方面:

  • 的图像资源ID;
  • 的文本蜇伤;
  • 在已经挂起的意图。

不要做增量窗口小部件的更新,像你这样一个普通的做 活动 - 不设置意图,再图像,再用文 反映了当前的信息。

家庭的应用程序运行作为一个独立的进程,它的状态可以得到失步 与你的小工具接收器。如果是这样,唯一拥有的 重新创建你的widget是你最近RemoteViews对象。如果是 完整,并拥有所有的部件,一切都将工作得很好。如果只 具有最近的文本或图像的变化,早期更新其中有 意图将丢失。

HTTP://kmansoft.wordpress.com / 2010/05/23 /部件,以及定向瓒 ...

- 克斯特亚

I have a bit of a strange bug with a widget I've coded- after the screen rotates the widget stops responding to onClick events. The code is exactly the same as in the Android Developer Documentation for App Widgets here. I've noticed other widgets from the market don't have this problem- is there a known workaround perhaps? I've tried tapping all over the place after a rotation so I don't think its the onClickPendingIntent not being resized after a rotation; it doesn't seem to be present at all.

I can't find an onRotation() kind of trigger for the AppWidgetProvider to redo the listening code in the event of a rotation so I'm quite unsure how to proceed...

Thanks!

解决方案

I received the following response from a post I made on Google Groups which resolved my issue. I cannot say whether it would resolve the original poster's problem, but I though I would post it, in case someone else runs across this problem. The link to my Google Groups post is:

http://groups.google.com/group/android-developers/browse_thread/thread/ca8c2958b6dc086c#


There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget.

I figured that it was recreating the Widget on rotation. The problem is, I don't seem to be getting any messages to that effect, and have no way (that I can see) of re-establishing the connection. How can I determine that a rotate has happened and set up a new onClick connection?

Like I said, you don't (determine or respond to an orientation change).

What you do, is make sure that every time your code pushes a RemoteViews object into the home application for your widget, it's complete in all respects:

  • Has image resource ids;
  • Has text stings;
  • Has pending intents.

Don't do "incremental" widget updates, like you would do with a regular activity - don't set the intents first, then the images, then the text reflecting current information.

The home app runs as a separate process, and its state can get out-of-step with your widget receiver. When it does, the only thing it has for re-creating your widget is your most recent RemoteViews object. If it's complete, and has all the parts, everything will work just fine. If it only has the most recent text or image change, the earlier updates which had the intents will be lost.

http://kmansoft.wordpress.com/2010/05/23/widgets-and-orientation-chan...

-- Kostya

这篇关于自动屏幕旋转禁用窗口小部件远程视窗onClick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆