acore 重启后 OnClick 不起作用

发布于 2024-10-07 01:07:35 字数 678 浏览 0 评论 0原文

我有一个具有 2 个不同 OnClick 意图的小部件,它们都按预期工作。除非 acore 重新启动后。我认为这与我的待定意图在重新启动后没有刷新有关。

谁能帮我解决这个问题吗?

这是我的 onRecieve()

        final RemoteViews views = new RemoteViews(context.getPackageName(), layoutID);
    views.setOnClickPendingIntent(R.id.TopRow, PendingIntent.getActivity(context, 0, new Intent(context, DigiClock.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
    AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views);
    alarmClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(alarmClockIntent);

I have a widget with 2 different OnClick intents, and they both work as expected. Except after an acore restart. I think it has something to do with my pendingintent not getting refreshed after the restart.

Can anyone help me with this issue?

This is from my onRecieve()

        final RemoteViews views = new RemoteViews(context.getPackageName(), layoutID);
    views.setOnClickPendingIntent(R.id.TopRow, PendingIntent.getActivity(context, 0, new Intent(context, DigiClock.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
    AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views);
    alarmClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(alarmClockIntent);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一桥轻雨一伞开 2024-10-14 01:07:35

正如我在此处所写的,您应该只生成一个实例远程查看,并在班级内共享。

As I've written here you should only produce a single instance of the RemoteView, and share it within the class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文