問題描述
widget 運行時間長了 或者手動殺死當前應用,widget上的控件點擊沒有反應 。 重新啟動APP后,控件點擊恢復正常。
解決方案
Intent topIntent = new Intent(context,WidgetReceiver.class).setAction(MONTH_TOP_CLICK);
PendingIntent topPendingIntent = PendingIntent.getBroadcast(context, widgetId, topIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.iv_month_top, topPendingIntent);
以前代碼是,Intent實例化時沒有傳參數(shù) 。
Intent topIntent = new Intent();