Widget

Android widget 运行时间长了,控件点击失效。

2016-09-19  本文已影响711人  皇马船长

问题描述

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实例化时没有传参数 。
Intent topIntent = new Intent();

上一篇下一篇

猜你喜欢

热点阅读