美文网首页Widget
Android widget 运行时间长了,控件点击失效。

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

作者: 皇马船长 | 来源:发表于2016-09-19 11:16 被阅读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();

    相关文章

      网友评论

        本文标题:Android widget 运行时间长了,控件点击失效。

        本文链接:https://www.haomeiwen.com/subject/ojdvettx.html