Two buttons with PendingIntents - Widget(两个带有 PendingIntents 的按钮 - 小部件)
问题描述
我正在创建一个带有两个按钮的小部件.其中一个更新小部件的内容,第二个必须启动一个活动.
I'm creating a widget with two buttons. One of them updates the content of the widget and the second one must launch an activity.
每个操作我都有两个 PendingIntent,但我不能让它们都工作.如果一个有效,另一个无效.
I have two PendingIntent for each action, but I can't make them both work. If one works the other one doesn't.
我已经修改了代码,不明白哪里出了问题.
I've revised the code and can't understand what's wrong.
任何帮助将不胜感激.
这是代码.
RemoteViews controls = new RemoteViews(context.getPackageName(), R.layout.miwidget);
Intent intent = new Intent("actony.com.ACTUALIZAR_WIDGET");
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
Intent intentSettings = new Intent();
intentSettings.setClass(context,WidgetConfig.class);
PendingIntent pendingIntentUpdate = PendingIntent.getBroadcast(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
controls.setOnClickPendingIntent(R.id.BtnActualizar, pendingIntentUpdate);
PendingIntent pendingIntentSettings = PendingIntent.getActivity(context, 0, intentSettings, 0);
controls.setOnClickPendingIntent(R.id.botonSettings, pendingIntentSettings);
推荐答案
当一个小部件中有两个或多个按钮时,请查看此链接以了解单击了哪个按钮..
Check this link to know which button has been clicked when there is two or more button in a widget..
https://stackoverflow.com/a/10733049/1331593
它应该可以工作...如果它不工作,请告诉我是什么问题...
It should work... IF it does not work please let me know what is the problem...
这篇关于两个带有 PendingIntents 的按钮 - 小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:两个带有 PendingIntents 的按钮 - 小部件
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01