2012-07-20 42 views
1

我有一个小部件,它的工作原理时,它不会......当它不!具体来说,如果我重新启动手机并点击小部件,东西就会发生。也许有一段时间,我可以继续点击小部件,一切正常。但最终(也许一个小时?)它只是停止工作。从logcat中,我的代码根本没有被执行,所以它就像从来没有发送到我的应用程序。我的思考过程是,因为在发生这种情况时,我的代码都不会执行,所以问题必须在清单中,或者其他我不知道的东西。Android小部件不执行...有时

下面是logcat的工作原理。从这里最后一行来自于我的代码:

07-20 13:00:54.638: E/MP-Decision(1265): UP Ld:85 Nw:1.990000 Tw:140 rq:1.000000 seq:141.000000 
07-20 13:00:54.818: I/InputReader(533): Touch event's action is 0x0 (deviceType=0) [pCnt=1, pending(waiting finished signal)=0, s=0.4 ] 
07-20 13:00:54.818: I/InputDispatcher(533): Delivering touch to current input target: action: 0x0 
07-20 13:00:54.818: D/lights(533): write_int /sys/class/leds/button-backlight/brightness = 255 
07-20 13:00:54.818: I/PowerManagerService(533): Ulight 0x3->0x7|0x0 
07-20 13:00:54.818: D/PowerManagerService(533): setLightBrightness : mButtonLight : 51 
07-20 13:00:54.908: I/InputReader(533): Touch event's action is 0x1 (deviceType=0) [pCnt=1, pending(waiting finished signal)=0, s=] 
07-20 13:00:54.908: I/InputDispatcher(533): Delivering touch to current input target: action: 0x1 
07-20 13:00:54.918: I/AudioPolicyManagerBase(229): getSituationVolume: isBTConnected:0 isHeadConnected:0 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): getParamFromPolicy deviceInt = 0, situationInt = 1, situationVolume = 0.500000 
07-20 13:00:54.918: D/AudioService(533): playSoundEffect() 
07-20 13:00:54.918: W/AudioTrack(533): Minimum buffer size corrected from 2048 to 4096 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): startOutput() output 1, stream 1, session 18 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): getDeviceForStrategy() from cache strategy 0, device 2 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): changeRefCount() stream 1, count 1 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): getDeviceForStrategy() from cache strategy 0, device 2 
07-20 13:00:54.918: V/AudioPolicyManagerBase(229): getNewDevice() selected device 2 
07-20 13:00:54.918: V/AudioPolicyManagerALSA(229): setOutputDevice() output 1 device 2 delayMs 0 force 0 
07-20 13:00:54.918: V/AudioPolicyManagerALSA(229): setOutputDevice output :0x1 mCurDevice:0x2 
07-20 13:00:54.918: V/AudioPolicyManagerALSA(229): setOutputDevice() setting same device 2 or null device for output 1 
07-20 13:00:54.918: D/PHCA_PhcaAppWidgetProvider(2316): onReceive(); action = com.skipmorrow.phca.PhcaAppWidgetProvider.WIDGET_CLICKED 

下面是从当它没有工作logcat的。

07-20 12:53:41.012: I/InputReader(534): Touch event's action is 0x0 (deviceType=0) [pCnt=1, pending(waiting finished signal)=0, s=0.160 ] 
07-20 12:53:41.012: I/InputDispatcher(534): Delivering touch to current input target: action: 0x0 
07-20 12:53:41.012: D/lights(534): write_int /sys/class/leds/button-backlight/brightness = 255 
07-20 12:53:41.012: I/PowerManagerService(534): Ulight 0x3->0x7|0x0 
07-20 12:53:41.012: D/PowerManagerService(534): setLightBrightness : mButtonLight : 51 
07-20 12:53:41.112: I/InputReader(534): Touch event's action is 0x1 (deviceType=0) [pCnt=1, pending(waiting finished signal)=0, s=] 
07-20 12:53:41.112: I/InputDispatcher(534): Delivering touch to current input target: action: 0x1 
07-20 12:53:41.112: I/AudioPolicyManagerBase(230): getSituationVolume: isBTConnected:0 isHeadConnected:0 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): getParamFromPolicy deviceInt = 0, situationInt = 1, situationVolume = 0.500000 
07-20 12:53:41.112: D/AudioService(534): playSoundEffect() 
07-20 12:53:41.112: W/AudioTrack(534): Minimum buffer size corrected from 2048 to 4096 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): startOutput() output 1, stream 1, session 153 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): getDeviceForStrategy() from cache strategy 0, device 2 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): changeRefCount() stream 1, count 1 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): getDeviceForStrategy() from cache strategy 0, device 2 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): getNewDevice() selected device 2 
07-20 12:53:41.112: V/AudioPolicyManagerALSA(230): setOutputDevice() output 1 device 2 delayMs 0 force 0 
07-20 12:53:41.112: V/AudioPolicyManagerALSA(230): setOutputDevice output :0x1 mCurDevice:0x2 
07-20 12:53:41.112: V/AudioPolicyManagerALSA(230): setOutputDevice() setting same device 2 or null device for output 1 
07-20 12:53:41.112: V/AudioPolicyManagerBase(230): releaseOutput() 1 

我没有看到任何突出的问题。

下面是该widgetProvider清单部分:

<receiver android:name="com.skipmorrow.phca.PhcaAppWidgetProvider" > 
    <intent-filter> 
     <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> 
     <action android:name="com.skipmorrow.phca.PhcaAppWidgetProvider.WIDGET_CLICKED" /> 
     <action android:name="com.skipmorrow.phca.PhcaAppWidgetProvider.VARIABLE_UPDATED" /> 
     <action android:name="android.appwidget.action.APPWIDGET_DELETED"/> 
     <action android:name="CORRECT_PIN_ENTERED_FOR_WIDGET"/> 
    </intent-filter> 
    <meta-data android:name="android.appwidget.provider" 
       android:resource="@xml/phca_widget_info" /> 
</receiver> 

顺便说一句,我使用的是三星Galaxy S3运行ICS。我的应用程序有minSdkVersion =“8”和targetSdkVersion =“8”

周末没有答案,但我做了一些故障排除。我仍然有问题,但我确实有其他信息。

小部件会从提供小部件文本的后台服务中更新。但是,小部件并不总是按照他们点击时应该做的事情做。换句话说,即使点击没有得到正确处理,我仍然可以更新小部件中的文本,所以小部件不会完全打破,如果有帮助的话。这似乎也是点击响应来来去去。也就是说,重新启动后,点击似乎可以工作一段时间,然后可能会停止工作一段时间,然后再次开始工作。我的AppWidgetProvider重写onUpdate,onEnabled,onDeleted,onDisabled和onReceive方法,但我只使用onReceive方法并手动跟踪每个意图。 onReceive方法的第一行写入日志,所以我可以看到当点击不起作用时,根本没有代码在我的AppWidgetProvider中执行,所以我仍然不认为问题出现在我的AppWidgetProvider中,并且可能在我的清单中?

难道这是一个权限问题?还是我没有正确注册接收器?

回答