我有一個小部件,它的工作原理時,它不會......當它不!具體來說,如果我重新啓動手機並點擊小部件,東西就會發生。也許有一段時間,我可以繼續點擊小部件,一切正常。但最終(也許一個小時?)它只是停止工作。從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中,並且可能在我的清單中?
難道這是一個權限問題?還是我沒有正確註冊接收器?